Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用simple_dom_html获取标题页时出错?_Php - Fatal编程技术网

Php 使用simple_dom_html获取标题页时出错?

Php 使用simple_dom_html获取标题页时出错?,php,Php,我有一个示例代码: include('simple_html_dom.php'); $url = 'http://api.nrelate.com/mpw_wp/0.51.4/?tag=nrelate_popular&domain=dongcam.vn&url=http%3A%2F%2Fdongcam.vn%2Ft10041&maxageposts=4320&nr_div_number=2&increment=1'; $html = file_get_htm

我有一个示例代码:

include('simple_html_dom.php');
$url = 'http://api.nrelate.com/mpw_wp/0.51.4/?tag=nrelate_popular&domain=dongcam.vn&url=http%3A%2F%2Fdongcam.vn%2Ft10041&maxageposts=4320&nr_div_number=2&increment=1';
$html = file_get_html($url);
// find all span tags with class=nr_post_title
foreach($html->find('span.nr_post_title') as $e)
    echo $e->innertext . '<br>';
include('simple_html_dom.php');
$url='1http://api.nrelate.com/mpw_wp/0.51.4/?tag=nrelate_popular&domain=dongcam.vn&url=http%3A%2F%2Fdongcam.vn%2Ft10041&maxageposts=4320&nr_div_number=2&increment=1';
$html=file\u get\u html($url);
//查找class=nr\u post\u title的所有跨度标记
foreach($html->find('span.nr\u post\u title')作为$e)
回显$e->innertext。“
';

=>错误无法使用
获取标题,如何修复它?

可能是nRelate.sw部分开始时把事情搞砸了?你能尝试一些基本的东西吗,比如这里的例子,它使用google.com?URL似乎返回用JavaScript包装的HTML。你为什么要用PHP简单Dom解析JavaScript?@SalmanA:我想得到一些行数据!API是否以任何其他格式(JSON、JSPNP、XML等)发布数据?输出甚至不是html,为什么将其视为html?