I am Trying to Crawl data from website and i did also but the problem is there is load more button, i can only crawl visible data, the data which is coming after click on load-more button that i can't be able to crawl.
Using preg_match_all :
$page = file_get_contents('https://www.healthfrog.in/chemists/medical-store/gujarat/surat');
preg_match_all(
'/<h3><a href="(.*?)">(.*?)<\/a><\/h3><p><i class="fa fa-map-marker"><\/i>(.*?)<\/p>/s',
$page,
$retailers, // will contain the article data
PREG_SET_ORDER // formats data into an array of posts
);
foreach ($retailers as $post) {
$retailer['name'] = $post[2];
$retailer['address'] = $post[3];
echo "<b>".$retailer['name']."</b><br/>".$retailer['address']."<br/><br/>";
}
Using DOMDocument :
$html = new DOMDocument();
@$html->loadHtmlFile('https://www.healthfrog.in/chemists/medical-store/gujarat/surat');
$xpath = new DOMXPath( $html );
$nodelist = $xpath->query('//*[@id="setrecord"]/div[@class="listing "]');
foreach ($nodelist as $n){
$retailer = $xpath->query('h3/a', $n)->item(0)->nodeValue."<br>";
$address = $xpath->query('p', $n)->item(0)->nodeValue;
echo "<b>".$retailer."</b><br/>".$address."<br/><br/>";
}
Any Idea how to grab whole data at a time?