...

View Full Version : Scan a Page



ArcticFox
07-30-2007, 08:10 AM
Is there a way to see if a word is listed on a page? For example, I'd like to know if http://www.ippages.com/voicexml/?ip=71.209.2.19 contains the word "Idaho".

How can I do this?

matak
07-30-2007, 09:05 AM
You can use my old search script :)


<?php
$uzorak = 'Idaho';
$tapeti = file_get_contents("http://www.ippages.com/voicexml/?ip=71.209.2.19");

work ($uzorak, $tapeti);
function work($uzorak, $tapeti) {

$duzina = strlen($uzorak);
$velicina = strlen($tapeti);

$b = array();
$a = 0;
while ($a <= $velicina){
$newstr = substr($tapeti, $a, $duzina);

if ($newstr == $uzorak){
$isfound = "Yes";
break;
}
else {
$isfound = "No";
}
$a++;
}
if ($isfound == "Yes") {
echo "Match found";
}
else {
echo "Sorry, no matches";
}
}
?>

It's case sensitive :D

firepages
07-30-2007, 06:55 PM
or ...



<?php
$uzorak = 'Idaho';
$tapeti = file_get_contents("http://www.ippages.com/voicexml/?ip=71.209.2.19");
if(strpos($tapeti, $uzorak)!==false){
echo 'found it !';
}
?>

matak
07-30-2007, 09:03 PM
or ...

my way is much faster, even though it looks more complicated. try to test it. you'll get interesting result..

ArcticFox
07-30-2007, 09:17 PM
Thanks guys. I'm always into smaller code - makes less work when I try to figure out how it works. But, speed-wise, how would I race these two? How is it the longer code would be faster than the compact one?

matak
07-30-2007, 09:52 PM
How is it the longer code would be faster than the compact one?

I don't know how, i just started the same script with his code, and with my code. His code had a way more lag than my code.

Can anyone post how to test the time in which the script is executed.

JordanW
07-30-2007, 10:58 PM
To test the speed of a script:

Place this code right at the very beginning:


<?php
function getmicrotime(){
list($msec,$sec)=explode(" ",microtime());
return ((float)$msec+(float)$sec);
}
$started=getmicrotime();
?>



And this code at the very end:


<?php
$ended=round(getmicrotime()-$started,4);
echo"Generated in ".$ended." seconds";
?>




~Jordan

matak
07-30-2007, 11:32 PM
OK, guess i was wrong. :o



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum