JSHINER Posted September 27, 2007 Share Posted September 27, 2007 <?php $seed = 'http://www.site.com/?page=10'; $data = file_get_contents($seed); if (preg_match_all("/http:\/\/[^\"\s']+/", $data, $links)) { header("Content-type: text/plain"); for ($i=0;$i<count($links[0]);$i++) { echo $links[0][$i]. "\n"; } } ?> The above gets all links from a page. But I need it to not only do page 10, but up to page 50. Can this spider multiple pages? If so, how can I do it? Quote Link to comment https://forums.phpfreaks.com/topic/70964-help-with-a-simple-spider/ Share on other sites More sharing options...
marcus Posted September 27, 2007 Share Posted September 27, 2007 for($i=10;$i<=50;$i++){ $seed = "http://www.site.com/?page=$i"; $data = file_get_contents($seed); if (preg_match_all("/http:\/\/[^\"\s']+/", $data, $links)){ header("Content-type: text/plain"); echo "Page $i\n:"; for ($j=0;$j<count($links[0]);$j++){ echo $links[0][$i]. "\n"; } echo "\n\n\n"; } } Quote Link to comment https://forums.phpfreaks.com/topic/70964-help-with-a-simple-spider/#findComment-356771 Share on other sites More sharing options...
MadTechie Posted September 27, 2007 Share Posted September 27, 2007 <?php header("Content-type: text/plain"); for ($n=1;$n<50;$n++) { $seed = "http://www.site.com/?page=$n"; $data = file_get_contents($seed); if (preg_match_all("/http:\/\/[^\"\s']+/", $data, $links)) { for ($i=0;$i<count($links[0]);$i++) { echo $links[0][$i]. "\n"; } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/70964-help-with-a-simple-spider/#findComment-356772 Share on other sites More sharing options...
JSHINER Posted September 27, 2007 Author Share Posted September 27, 2007 Worked perfect thanks! Now, how can I do the same thing with ?=A ... to ?=Z ... ? Quote Link to comment https://forums.phpfreaks.com/topic/70964-help-with-a-simple-spider/#findComment-356789 Share on other sites More sharing options...
MadTechie Posted September 27, 2007 Share Posted September 27, 2007 i guess you could try replacing for ($n=1;$n<50;$n++) { with for ($l=65;$l<91;$l++) { $n = chr($l); Quote Link to comment https://forums.phpfreaks.com/topic/70964-help-with-a-simple-spider/#findComment-356799 Share on other sites More sharing options...
JSHINER Posted October 2, 2007 Author Share Posted October 2, 2007 Alphabetical worked. Now for the newest question: javascript:function('MEMBERNAME') How can I get my code to pull "MEMBERNAME" out of there using preg_match_all ? Quote Link to comment https://forums.phpfreaks.com/topic/70964-help-with-a-simple-spider/#findComment-360339 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.