使用PHP抓取一个包含img src和jpg和webp的网站

时间:2020-03-06 22:22:37

标签: php html web-scraping simple-html-dom

我正在使用simplehtmldom抓取网址。一切正常,但由于该网址使用的是带有.webp文件和jpg后备广告的图片,因此我无法获取这些图片链接(src)。我的目标网址使用的是img src,如下所示。

https://static-01.daraz.pk/p/4bd8844ef66b66f4f0ba441dea6d33a6.jpg_340x340q80.jpg_.webp

任何想法我该如何获取img src?提前致谢 下面是我的代码

// Create DOM from URL or file
$html = file_get_html('https://www.daraz.pk/products/opal-fire-stone-oval-shape-55-carat-i125548843-s1283634122.html?');

// Find all images 
foreach($html->find('img') as $element) 
       echo $element->src . '<br>';

// Find all links 
foreach($html->find('a') as $element) 
       echo $element->href . '<br>';

这是我要抓的链接。

https://www.daraz.pk/products/opal-fire-stone-oval-shape-55-carat-i125548843-s1283634122.html?

0 个答案:

没有答案