使用Symfony Panther抓取动态网站内容

时间:2019-11-13 16:06:11

标签: php web-scraping symfony-panther

这是我需要获取的HTML代码

<ul class="DataView ProductList padded-items js-data-view">
<li class="data-item">
…
</il>

<li class="data-item">
...
</il>

<div class="sto-BF_btf_C36058-w-butterfly">
...
</div>

<li class="data-item">
…
</il>

</ul>

$client = \Symfony\Component\Panther\Client::createChromeClient();
$client->get($url);
$crawler = $client->waitFor('.sto-BF_btf_C36058-w-butterfly'); // doesn't work, element not found
$productlist = $crawler->filter('.ProductList')->html();
echo $productlist;

问题是动态添加的div标签“ sto-BF_btf_C36058-w-butterfly”。

有没有办法等到页面完全加载然后再获取内容?

0 个答案:

没有答案