【问题标题】:Goutte Crawler can't get certain classname valuesGoutte Crawler 无法获取某些类名值
【发布时间】:2019-10-29 04:50:53
【问题描述】:

我正在尝试从网站获取一系列产品名称。我正在使用fabpot/goutte。我可以从网站上获取某些类值,但是当我尝试获取产品名称或产品价格时,我会得到类似 {{ProductName}} 的内容。

这是我的代码:

$client = new \Goutte\Client();

$crawler = $client->request('GET','http://www.thefirestore.com/store/category.aspx/categoryId/577/1010-Helmets-Cairns-Helmets/#/orderby/9');
$crawler->filter('.product-name')->each(function ($node){
  echo $node->text().'<br>';
});

谢谢,

【问题讨论】:

    标签: php symfony web-crawler goutte


    【解决方案1】:

    那是因为页面的html返回的只是一个模板,而产品数据是通过api提供的,所以你甚至不需要爬虫来获取产品列表,只需在他的api上进行GET即可。

    【讨论】:

    • 感谢您的帮助@kiske
    猜你喜欢
    • 2020-04-22
    • 1970-01-01
    • 2015-06-25
    • 2016-08-27
    • 1970-01-01
    • 1970-01-01
    • 2021-02-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多