1
想知道如何在精確的位置獲取網站中的數據;例如在div class「test」中的body中,並在href中的我自己的網站上檢索它。使用HTML提取div中的數據
想知道如何在精確的位置獲取網站中的數據;例如在div class「test」中的body中,並在href中的我自己的網站上檢索它。使用HTML提取div中的數據
這叫做刮擦,你可以用很多不同的方法做到。如果有問題的網站是屬於你的,你可以很容易地使用JavaScript來獲得一個div的內容。例如:
var content = document.getElementById("divID").html;
你想通過類來檢索它,但類名稱不一定是唯一的單個元素,這樣就行不通了。
如果你沒有自己的網站有問題,你仍然可以用PHP解析它獲取內容使用the curl command:
// create curl resource
$ch = curl_init();
// set url
curl_setopt($ch, CURLOPT_URL, "example.com");
//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// $output contains the output string
$output = curl_exec($ch);
// close curl resource to free up system resources
curl_close($ch);
是啊謝謝男人! :) – AndrewBr
http://stackoverflow.com/questions/17050563/how-to-鏈接到特定的文本在網頁中使用的唯一url – nanocv
也相關:http://stackoverflow.com/q/680562/3345375 – jkdev