View Full Version : Need help with a little php script


viper799
02-21-2005, 08:30 PM
Hello I need a little help with a php script that I am working on to grab links of a web page then check for my link and display my link and anchor text

here is what I have


<?php
// URL1
$url="http://dreamworx.cz/";

// URL2
//$url="http://www.righthanddrivejeeps.us/temp.html";

$domain="www.righthanddrivejeeps.us";
$remote = fopen($url, 'r');
$html = fread($remote, 10342400);
fclose($remote);
preg_match_all("|<[^>]+>(.*)</[^>]+>|U",
$html,
$out, PREG_SET_ORDER);

for ($i=0; $i< count($out); $i++)
{

if (preg_match("/\b$domain\b/i", $out[$i][0])) {
// display if one of the links is my link, full code & anchor text
echo $out[$i][0] . ", " . $out[$i][1] . "<br>";

}
}
?>



I can get url2 to work but not url1 they both have links to the $domain

please I could use some help here I plan to add on to update my link dir DB with the anchor text of the link parnter so I can have an count on the links with the same anchor text.

thanks

l3vi
02-23-2005, 11:00 PM
<?
function URLopen($url)
{
// Fake the browser type
ini_set('user_agent','MSIE 4\.0b2;');
$dh = fopen("$url",'r');
$result = fread($dh,8192);
fclose($dh);
return $result;
}
$SearchDomain = URLopen('http://dreamworx.cz/');
$MyDomain = "www.righthanddrivejeeps.us";
preg_match_all("|<[^>]+>(.*)</[^>]+>|U", $SearchDomain, $Match, PREG_SET_ORDER);
foreach ($Match as $value){
if (preg_match("/\b$domain\b/i", $value)) {
echo "Link found<br>\n";
}
}
?>


The cz site is a super spam site.. Has your link almost 100 times.