Here is the code for my Web Crawler:
/
<html>
<head><title>Web Crawler</title></head>
<body>
<form id="form1" method="post" action="">
<label>URL:
<input name="url" type="text" id="url" value="<?php $url; ?>" size="65" maxlength="255" />
</label>
<br />
<br />
<label>
<input type="submit" name="Submit" value="Submit" />
</label>
<label>
<input name="Reset" type="reset" id="Reset" value="Reset" />
</label>
<br />
</form>
</body>
</html>
<?php
if (isset($_POST['url'])) {
$url = $_POST['url'];
$f = @fopen($url,"r");
while( $buf = fgets($f,1024) )
{
$buf = fgets($f, 4096);
preg_match_all("/<\s*a\s+[^>]*href\s*=\s*[\"']?([^\"' >]+)[\"' >]/isU",$buf,$words);
for( $i = 0; $words[$i]; $i++ )
{
for( $j = 0; $words[$i][$j]; $j++ )
{
$cur_word = strtolower($words[$i][$j]);
print "$cur_word<br>";
}
}
}
}
?>
No comments:
Post a Comment