PHP cURL没有从某个角度显示部分内容

PHP cURL没有从某个角度显示部分内容,php,curl,domdocument,domxpath,Php,Curl,Domdocument,Domxpath,我努力了一段时间,以使这项工作,但似乎我错过了一些东西。场景如下: 我正试图通过DOMXpath查询从一个使用PHP和cURL的网站上获取一些信息。我得到的任何信息,直到某一点,从这一点和以下,我没有得到任何东西…空白。我使用的脚本如下所示: $target_url = "https[:]//[www][.]bankofalbania[.]org/Tregjet/Kursi_zyrtar_i_kembimit/"; //Remove [ and ] from url $userAgent = '

我努力了一段时间,以使这项工作,但似乎我错过了一些东西。场景如下: 我正试图通过DOMXpath查询从一个使用PHP和cURL的网站上获取一些信息。我得到的任何信息,直到某一点,从这一点和以下,我没有得到任何东西…空白。我使用的脚本如下所示:

$target_url = "https[:]//[www][.]bankofalbania[.]org/Tregjet/Kursi_zyrtar_i_kembimit/"; //Remove [ and ] from url
$userAgent = 'Googlebot/2.1 (http://www.googlebot.com/bot.html)';

$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
curl_setopt($ch, CURLOPT_URL,$target_url);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 1000);

$html= curl_exec($ch);
if (!$html) {
    echo "<br />cURL error number:" .curl_errno($ch);
    echo "<br />cURL error:" . curl_error($ch);
    exit;
}

// parse the html into a DOMDocument
$document = new DOMDocument();
libxml_use_internal_errors(true);
$document->loadHTML($html);
libxml_clear_errors();
$selector = new DOMXPath($document);

$anchors = $selector->query('/html/body/div[1]/section[1]/div/div[2]/div[2]/div[2]/div/table[1]/tbody/tr[1]/td[1]');
    foreach($anchors as $div) { 
        $value = $div->nodeValue;
        echo $value;
}
$anchors = $selector->query('//table[@class="table table-sm table-responsive w-100 d-block d-md-table table-bordered m-0"]/tbody/tr[1]/td[3]');
但结果是一样的…空! 我不知道我在这里错过了什么,但我不能让它运行。 我期待从$target_url页面的表格中得到美元的价值。 提前感谢:-

html中没有tbody标记,与Javascript不同,PHP不会自动添加它,在使用浏览器提供的开发工具时请记住这一点。另外,USD的金额在第三个单元格中,因此正确的XPath查询是:

/html/body/div[1]/section[1]/div/div[2]/div[2]/div[2]/div/table[1]/tr[1]/td[3]

非常感谢你的帮助。我不知道。我应该四处搜索可能导致相同问题的任何其他标签。现在一切都很顺利。再次感谢!另外,我与其他网站有一个问题,我正在寻找的字符串是内联javascript。有可能得到它吗?谢谢