簡體   English   中英

需要幫助才能找到正確的 xpath

[英]need help to find correct xpath

我有以下這個天氣網站

而且我需要使用 Xpath 但icant返回查詢!

我正在使用這個 xPath 並且必須返回 2 Row

$xpath->query('/html/body/table[3]/tbody/tr/td/table/tbody/tr/td[2]/p/table/tbody/tr/td/font/div/center/table/tbody/tr[1]/td[1]/font/font/b');

但不返回任何東西:

請填寫此 xpath

我正在使用這個 cod butt 顯示錯誤

可捕獲的致命錯誤:無法將 class DOMNodeList 的 Object 轉換為第 23 行 /home/mysite/curl.php 中的字符串

<?php
$url="http://www.irimo.ir/farsi/current/index.asp?station=40770";
function file_get_contents_curl($url) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_URL, $url);
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;
}

$dom = new DomDocument();
@$dom->loadHTML($allcont);
$xpath = new DomXPath($dom);

$return = $xpath->query('/html/body/table[3]/tbody/tr/td/table/tbody/tr/td[2]/p/table/tbody/tr/td/font/div/center/table/tbody/tr[3]/td/font/b');

echo $return;
echo $xpath;

?>

嘗試

$xpath->query('/html/body/table[3]/tbody/tr/td/table/tbody/tr/td[2]/p/table/tbody/tr/td/font/div/center/table/tbody/tr[3]/td/font/b');

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM