|
Posted by charliefortune on 01/10/06 19:30
I want to read lots of pages looking for the expression 'sold out'. I
am currently using fgets() but unfortunately this picks up comments and
javascript which may include the expression.
How can I get just what the viewer would see in their browser ?
//check line by line
while (! feof($fp)){
$buffer = fgets($fp,4069);
//see if the price we have is somewhere on the page
if (strstr($buffer,$a_row['price'])){
$found['price']=1;
}
//look for the words 'out of stock'
$string = "out of stock";
if (strstr($buffer,$string)){
$found['stock'] = 0;
}
elseif (strstr($buffer,"SOLD OUT")){
$found['stock'] = 0;
}
}
//after reading page....
if ($found['price'] == 0){
print "This stock item : <a href=\"".$a_row['bare_url']."\"
target=\"_blank\">".$a_row['id_stock']."</a> has price problems<br>";
}
if ($found['stock'] == 0){
print "This stock item : <a href=\"".$a_row['bare_url']."\"
target=\"_blank\">".$a_row['id_stock']."</a> appears to be out of
stock<br>";
$query = "UPDATE stock SET id_flag = 1 WHERE id_stock =
".$a_row['id_stock'].";";
mysql_query($query);
}
fclose($fp);
}
thanks
Navigation:
[Reply to this message]
|