2012-11-22 55 views
0

我遇到了一些奇怪的simplehtmldom行爲。simplehtmldom奇怪的行爲

我從某個頁面得到$newlink,然後把它放到另一個捲曲中,返回空白數據。如果我改變

curl_setopt($ch1, CURLOPT_URL, $newlink); 

curl_setopt($ch1, CURLOPT_URL, "http://www.granma.cu/italiano/sport/22-noviembre-iaaf.html"); 

正在顯示的數據。我的錯誤在哪裏?

<?php header("Content-Type: text/html; charset=utf-8"); ?> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 

<?php 
require dirname(__FILE__) . '/simple_html_dom.php'; 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, 'http://youlichika.netii.net/aaa.php'); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); 
$htmls = curl_exec($ch); 
curl_close($ch); 
$html = str_get_html($htmls); 
$newlink = $html->find('p',0); 
echo $newlink; 
$ch1 = curl_init(); 
curl_setopt($ch1, CURLOPT_URL, $newlink); 
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch1, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); 
$newhtml = curl_exec($ch1); 
curl_close($ch1); 
echo $newhtml; 
?> 

回答

0

您需要使用$newlink->innertext才能獲取<p>標記之間的內容。