Jump to content

How to make my crawler go to the next page?


swampone

Recommended Posts

What other pages do you wish to call? You could crawl recursively if you are attempting to create your own web crawler, but this will potentially never end. To call recursively you will have to extract all the links from the page (either using preg_match or some other function) then create a foreach() loop to loop through each of those files calling the same function your currently in.

 

A quick pseudo example.

 

function crawl( $url ) {
  $file = file_get_contents( $url );

  if ( preg_match ( $some_valid_url_pattern, $file, $output ) ) {
    foreach ( $output as $url ) {
      crawl( $url );
    }
  }
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.