Using CURL and Simple HTML DOM Parser to get content from website. Getting response in object. I'm using it to get the link of all images from the product page of this website https://www.geekbuying.com/ It works with most pages, this one for example https://www.geekbuying.com/item/eufy-MACH-V1-Cordless-Vacuum-Cleaner-520574.html
With other pages, which are in fact identical, it doesn't get anything and I just can't figure out why. This one for example https://www.geekbuying.com/item/eufy-Clean-G40-Hybrid--Robot-Vacuum-Cleaner-520591.html
include "simple_html_dom.php";
$link = "https://www.geekbuying.com/item/eufy-Clean-G40-Hybrid--Robot-Vacuum-Cleaner-520591.html"; //don't works
$link = "https://www.geekbuying.com/item/eufy-MACH-V1-Cordless-Vacuum-Cleaner-520574.html"; //works
function get_content($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$htmlContent = curl_exec($ch);
curl_close($ch);
$dom = new simple_html_dom();
$dom->load($htmlContent);
foreach($dom->find('img') as $element){
$immagine = $element->src;
echo "$immagine <br />";
}
}
get_content($link);
The script should allow me to get the link of all the images in an external page, but with some it doesn't work.