0

I met some strange simplehtmldom behaviour.

I get $newlink from some page, then put it into another curl, return blank data. If I change

curl_setopt($ch1, CURLOPT_URL, $newlink);

to

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

the data is being displayed. Where's my error?

<?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;
?>
Marty McVry
  • 2,838
  • 1
  • 17
  • 23
yuli chika
  • 9,053
  • 20
  • 75
  • 122

1 Answers1

0

You need to use $newlink->innertext to get the content in between the <p> tags.

Steve
  • 2,936
  • 5
  • 27
  • 38