use*_*331 2 ajax web-scraping symfony
在这里,我需要点击$('button-see-more'),它会触发ajax调用并在页面上加载更多内容.我正在尝试
$link = $crawler->selectLink('See More Products')->link();
$crawler = $client->click($link);
Run Code Online (Sandbox Code Playgroud)
但那当然不会有效,因为它没有任何锚标记.这是HTML,按钮实际上是一个元素,我想模拟它的点击
<div class="paging">
<div class="mtl">
<div class="button-see-more txtCenter" data-current-page="1" data-total-pages="3" data-txt-seemore="See More Products" data-txt-loading="Loading More Items for Phones">
<span class="i-loader hidden"></span>
<span class="text">See More Products</span>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?谢谢
使用抓取工具,您无法从javascript中检测到链接,但如果您已经有ajax链接,则可以通过此方法模拟您的请求
$crawler = $client->request('GET', '/foo/', array(), array(), array(
'HTTP_X-Requested-With' => 'XMLHttpRequest',
));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1442 次 |
| 最近记录: |