[英]Unable to scrape particular data from a URL
I want to scrape this URL . 我想抓取这个URL 。
I am using phpQuery library for this purpose. 我为此使用phpQuery库。
I want to scrape #weedmenuPane
from that link which contains some items and its prices. 我想从该链接中抓取#weedmenuPane
,其中包含一些物品及其价格。
Problem is, when I get scraped HTML, the required DIV is not in the scraped HTMl. 问题是,当我抓取HTML时,所需的DIV不在抓取的HTM1中。
I have checked with Firebug but it is not coming from any AJAX call. 我已经检查了Firebug,但它不是来自任何AJAX调用。
I thought it was coming by some kind of JS operation after HTML is loaded but I have also checked by disabling JS
in my browser, and that DIV is there, means not coming by any JS operation. 我以为它是在HTML加载后通过某种JS操作来实现的,但是我也通过在浏览器中禁用JS
进行了检查,并且DIV在那里,这意味着不通过任何JS操作来实现。
I want to know how it is coming and how it is being generated. 我想知道它是如何来的以及它是如何产生的。
Here is code I have tried. 这是我尝试过的代码。
$html = file_get_contents($link, false, $context);
$html = phpQuery::newDocumentHTML($html);
echo pq("",$html);
echo pq("#weedmenuPane",$html)->html() . " here";
So, I have downloaded phpQuery and written a little test with your url. 因此,我已经下载了phpQuery并使用您的网址进行了一些测试。
This : 这个 :
<?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";
?>
Return the content of the #weedmenuPane DIV. 返回#weedmenuPane DIV的内容。
So try to use this code or show me your code and we will find your problem. 因此,尝试使用此代码或向我显示您的代码,我们会找到您的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.