[英]Unable to scrape particular data from a URL
我想抓取这个URL 。
我为此使用phpQuery库。
我想从该链接中抓取#weedmenuPane
,其中包含一些物品及其价格。
问题是,当我抓取HTML时,所需的DIV不在抓取的HTM1中。
我已经检查了Firebug,但它不是来自任何AJAX调用。
我以为它是在HTML加载后通过某种JS操作来实现的,但是我也通过在浏览器中禁用JS
进行了检查,并且DIV在那里,这意味着不通过任何JS操作来实现。
我想知道它是如何来的以及它是如何产生的。
这是我尝试过的代码。
$html = file_get_contents($link, false, $context);
$html = phpQuery::newDocumentHTML($html);
echo pq("",$html);
echo pq("#weedmenuPane",$html)->html() . " here";
因此,我已经下载了phpQuery并使用您的网址进行了一些测试。
这个 :
<?php
require 'phpQuery-onefile.php';
$url= "https://weedmaps.com/deliveries/green-door-west";
$HTML = file_get_contents($url);
$pq = phpQuery::newDocumentHTML($HTML);
$div = pq('#weedmenuPane', $pq);
echo $div; // Content of #weedmenuPane
// or with your code
echo pq("#weedmenuPane", $pq)->html() . " here";
?>
返回#weedmenuPane DIV的内容。
因此,尝试使用此代码或向我显示您的代码,我们会找到您的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.