0
我試圖將外部網頁的某些信息導入到數組中。將表中的元素插入到數組中
這裏是閱讀頁面的代碼:
$url = 'http://dsrd.uc.cl/dara/libcursos/periodo21/ptj/ptj_5_data.html';
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
curl_setopt ($ch, CURLOPT_HTTPHEADER, array (
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Accept-Language: en-us,en;q=0.5", "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7"
));
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
// get the source code
$html = curl_exec($ch);
,這裏是代碼即可獲得列到一個數組
$doc = new DOMDocument();
$doc->loadHTML($html);
$table = $doc->getElementsByTagName("table")->item(0);
$rows = $table->getElementsByTagName("td");
for ($i = 0; $i<100; $i++)
{
$curso[$i] = $rows->item($i);
/* Find columns and add it to your array */
}
print_r($curso);
但即時通訊只獲得了充滿「一個DOMElement對象數組()「
任何消耗? THX
UPDATE
忘了添加 - >的nodeValue; ....只是愚蠢
THX反正