简体   繁体   中英

Unable to scrape particular data from a URL

I want to scrape this URL .

I am using phpQuery library for this purpose.

I want to scrape #weedmenuPane from that link which contains some items and its prices.

Problem is, when I get scraped HTML, the required DIV is not in the scraped HTMl.

I have checked with Firebug but it is not coming from any AJAX call.

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.

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.

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.

So try to use this code or show me your code and we will find your problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM