Skip to content

Instantly share code, notes, and snippets.

@Tonel
Created August 13, 2022 12:00
Show Gist options
  • Select an option

  • Save Tonel/19b11a774381a3090d427e97a6029fcf to your computer and use it in GitHub Desktop.

Select an option

Save Tonel/19b11a774381a3090d427e97a6029fcf to your computer and use it in GitHub Desktop.
<?
// iterate over all "/shop/page/X" pages and retrieve all product data
for ($paginationNumber = 1; $paginationNumber <= $highestPaginationNumber; $paginationNumber++) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://scrapeme.live/shop/page/$paginationNumber/");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$pageHtml = curl_exec($curl);
curl_close($curl);
$paginationHtmlDomParser = HtmlDomParser::str_get_html($pageHtml);
// scraping logic...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment