$str = file_get_contents($page_data["url"]);
if(strpos($str, $find) == true)
{
echo $page_data["referer_url"]. ' - gevonden';
$keywords = $_POST['keywords'];
if($page_data["header"]){
echo "<table border='1' >";
echo "<tr><td width='300'>Status:</td><td width='500'> ".strtok($page_data["header"], "\n")."</td></tr>";}
else "<table border='1' >";
// PRINT EERSTE LIJN
echo "<tr><td>Page requested:</td><td> ".$page_data["url"]."</td></tr>";
// PRINT STATUS WEBSITE
// PRINT WEBPAGINA
echo "<tr><td>Referer-page:</td><td> ".$page_data["referer_url"]."</td></tr>";
// CONTENT ONTVANGEN?
if ($page_data["received"]==true)
echo "<tr><td>Content received: </td><td>".$page_data["bytes_received"] / 8 . " Kbytes</td></tr></table>";
else
{
echo "<tr><td>Content:</td><td>Not received</td></tr></table>";
}
$domain = $_POST['domain'];
$link = mysql_connect('localhost', 'crawler', 'password');
if (!$link)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("crawler");
if(empty($page_data["referer_url"]))
$page_data["referer_url"] = $page_data["url"];
strip_tags($str, '<p><b>');
mysql_query("INSERT INTO crawler (id, domain, url, keywords, data) VALUES ('', '".$page_data["referer_url"]."', '".$page_data["url"]."', '".$keywords."', '".mysql_real_escape_string($str) . "' )");
echo "<br><br>";
echo str_pad(" ", 5000); // "Force flush", workaround
flush();
}
As you can see I already got the keywords finded, now i need the part around it.
Somebody told me i have to read the page in a treestructure and after I can use the
part around my founded keyword (div, p, etc.)