First of all, I love Zymic Back. I used to get help with all my design needs here.
Now, back to business:
I want to index links from a page into a database.
I got this code from searching on google, but I can't get it to crawl the website.
CODE
<?php
// This script will extract all the hyperlinks from a given web page
// To use this script, you must provide a link back to www.WAY2WEB.net
// Thanks!
// © 2007 - Anthony Eden | www.WAY2WEB.net
function hyperlinkextract($s1,$s2,$s){
$myarray=array();
$s1=strtolower($s1);
$s2=strtolower($s2);
$L1=strlen($s1);
$L2=strlen($s2);
$scheck=strtolower($s);
do{
$pos1 = strpos($scheck,$s1);
if($pos1!==false){
$pos2 = strpos(substr($scheck,$pos1+$L1),$s2);
if($pos2!==false){
$myarray[]=substr($s,$pos1+$L1,$pos2);
$s=substr($s,$pos1+$L1+$pos2+$L2);
$scheck=strtolower($s);
}
}
} while (($pos1!==false)and($pos2!==false));
return $myarray;
}
$content = @get_file_contents('http://www.way2web.net/');
$myarray = hyperlinkextract("href=\"","\"",$content);
// Process all the links
foreach($myarray as $key => $val) {
echo "<br />".$val."\n";
}
?>
// This script will extract all the hyperlinks from a given web page
// To use this script, you must provide a link back to www.WAY2WEB.net
// Thanks!
// © 2007 - Anthony Eden | www.WAY2WEB.net
function hyperlinkextract($s1,$s2,$s){
$myarray=array();
$s1=strtolower($s1);
$s2=strtolower($s2);
$L1=strlen($s1);
$L2=strlen($s2);
$scheck=strtolower($s);
do{
$pos1 = strpos($scheck,$s1);
if($pos1!==false){
$pos2 = strpos(substr($scheck,$pos1+$L1),$s2);
if($pos2!==false){
$myarray[]=substr($s,$pos1+$L1,$pos2);
$s=substr($s,$pos1+$L1+$pos2+$L2);
$scheck=strtolower($s);
}
}
} while (($pos1!==false)and($pos2!==false));
return $myarray;
}
$content = @get_file_contents('http://www.way2web.net/');
$myarray = hyperlinkextract("href=\"","\"",$content);
// Process all the links
foreach($myarray as $key => $val) {
echo "<br />".$val."\n";
}
?>
I just want it to crawl and echo the links for a start, then I'll take it from there. Does anyone know what's wrong with this bit? Or maybe sugguest another code/script?