--------------------------------------------------------------------------------
Ik heb een zoekmachine script gedownload, maar op regel 21 bij joinen zit er een fout.
$text1 = join("",file($c['url']));
Een vriend zegt dat het aan de Regx ligt, omdat het wel werkt bij Altavista.
$eng[0]['reg'] = "/<p><A HREF=(.*?)>(.*?)<\/A><font.*?<br>(.*?)<br>/";
ziet er iemand een fout? voorbeeld @ http://www.daweb.nl/google.php?search=daweb
HELE SCRIPT:
<?php
#- Start search
if($search) {
$q = urlencode($search);
$start = time();
$eng[0]['url'] = "http://www.google.com/search?hl=en&safe=off&q=$search";
$eng[0]['name'] = "Google";
$eng[0]['reg'] = "/<p><A HREF=(.*?)>(.*?)<\/A><font.*?<br>(.*?)<br>/";
$eng[0]['strip'] = "\n";
$urls = array();
$out = array();
$y=0;
foreach($eng as $c)
{
$text1 = join("",file($c['url']));
if($c[strip])
$text1 = ereg_replace($c[strip],"",$text1);
preg_match_all($c['reg'],$text1,$matches);
$num = count($matches[0]);
for($x=0;$x<$num;$x++) {
$url = strip_tags($matches[1][$x]);
$title = strip_tags($matches[2][$x]);
$description = strip_tags($matches[3][$x]);
$engine = $c[name];
if($out["$url"])
{
$out["$url"][engine] .= ", $engine";
}
else
{
$out["$url"][title] = $title;
$out["$url"][description] = $description;
$out["$url"][engine] = $engine;
}
$y++;
}
}#rof
$secs = time() - $start;
print "Gezocht naar: $search.<br>";
print "$y resultaten gevonden in $secs seconden.<br><br>";
print "<OL>";
#print "<pre>";
#print_r($out);
#print "</pre>";
while(list($url,$rec) = each($out))
{
extract($rec);
print "
<li>
<a href=$url style=\color:000099;\ target=\_blank\><b>$title</b></a><BR>
$description
<FONT size=1><BR>$url<br></FONT>
<FONT size=1 color=000099>$engine</FONT>
<BR><BR>";
}
print "</OL>";
print "
</font>
</BODY>
</HTML>
";
} #end search
?>
Ik heb een zoekmachine script gedownload, maar op regel 21 bij joinen zit er een fout.
$text1 = join("",file($c['url']));
Een vriend zegt dat het aan de Regx ligt, omdat het wel werkt bij Altavista.
$eng[0]['reg'] = "/<p><A HREF=(.*?)>(.*?)<\/A><font.*?<br>(.*?)<br>/";
ziet er iemand een fout? voorbeeld @ http://www.daweb.nl/google.php?search=daweb
HELE SCRIPT:
<?php
#- Start search
if($search) {
$q = urlencode($search);
$start = time();
$eng[0]['url'] = "http://www.google.com/search?hl=en&safe=off&q=$search";
$eng[0]['name'] = "Google";
$eng[0]['reg'] = "/<p><A HREF=(.*?)>(.*?)<\/A><font.*?<br>(.*?)<br>/";
$eng[0]['strip'] = "\n";
$urls = array();
$out = array();
$y=0;
foreach($eng as $c)
{
$text1 = join("",file($c['url']));
if($c[strip])
$text1 = ereg_replace($c[strip],"",$text1);
preg_match_all($c['reg'],$text1,$matches);
$num = count($matches[0]);
for($x=0;$x<$num;$x++) {
$url = strip_tags($matches[1][$x]);
$title = strip_tags($matches[2][$x]);
$description = strip_tags($matches[3][$x]);
$engine = $c[name];
if($out["$url"])
{
$out["$url"][engine] .= ", $engine";
}
else
{
$out["$url"][title] = $title;
$out["$url"][description] = $description;
$out["$url"][engine] = $engine;
}
$y++;
}
}#rof
$secs = time() - $start;
print "Gezocht naar: $search.<br>";
print "$y resultaten gevonden in $secs seconden.<br><br>";
print "<OL>";
#print "<pre>";
#print_r($out);
#print "</pre>";
while(list($url,$rec) = each($out))
{
extract($rec);
print "
<li>
<a href=$url style=\color:000099;\ target=\_blank\><b>$title</b></a><BR>
$description
<FONT size=1><BR>$url<br></FONT>
<FONT size=1 color=000099>$engine</FONT>
<BR><BR>";
}
print "</OL>";
print "
</font>
</BODY>
</HTML>
";
} #end search
?>