[英]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.