由网友(为不挂科而奋斗)分享简介:这里我需要点击$('按钮看,更多的'),它会触发一个ajax打电话页面上加载更多的东西。我试图用Here I need to click $('button-see-more') which triggers an ajax call and loads more stuff on the page. I'm tr...
这里我需要点击$('按钮看,更多的'),它会触发一个ajax打电话页面上加载更多的东西。我试图用
Here I need to click $('button-see-more') which triggers an ajax call and loads more stuff on the page. I'm trying with
$link = $crawler->selectLink('See More Products')->link();
$crawler = $client->click($link);
但是,这ofcourse是行不通的,因为它没有任何锚标记。 这是HTML,按钮其实是一个元素,我想模拟就可以点击
But that ofcourse won't work because it doesn't have any anchor tag. This is the HTML, the button is actually a element, I want to simulate a click on it
<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>
我怎么能这样做?谢谢
How can I do that? Thanks
推荐答案
通过爬虫无法检测到来自JavaScript的一个环节, 但如果你已经有一个AJAX的链接,你可以用这种方法模拟您的要求
With crawler you can't detect a link from javascript, but if you have already an ajax link, you can simulate your request by this method
$crawler = $client->request('GET', '/foo/', array(), array(), array(
'HTTP_X-Requested-With' => 'XMLHttpRequest',
));
相关推荐
最新文章