【发布时间】:2017-02-21 07:35:50
【问题描述】:
我一直在尝试从网站上抓取内容,并且在某些网站上取得了成功。但是我的代码无法从 Flipkart.com 中抓取内容。我使用 HTML DOM PARSER,这是我的代码..
<?php
include ('simple_html_dom.php');
$scrape_url = 'https://www.flipkart.com/lenovo-f309-2-tb-external-hard-disk-drive/p/itmehwha6zkhkgfw';
$html = file_get_html($scrape_url);
foreach($html->find('h1._3eAQiD') as $title_s)
echo $title_s->plaintext;
foreach($html->find('div.hGSR34') as $ratings_s)
echo $ratings_s->plaintext;
?>
此代码给出空结果。有人可以让我知道问题所在吗?有没有其他方法可以从这个网站上抓取内容?
【问题讨论】:
-
内容可能令人窒息。或者你可能期望一些 js 加载的内容在那里。如果您能缩小范围,这将对我们有所帮助。
-
我认为内容是 js 加载的。有没有办法用 php 报废内容?
-
你可以先run it through phantomjs。如果你想发疯,还有一些 php selenium 库。
标签: php simple-html-dom