0

我遇到了一些奇怪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;
?>
4

1 回答 1

0

您需要使用$newlink->innertext来获取<p>标签之间的内容。

于 2012-11-22T15:49:12.703 回答