Php 简单的html dom-

Php 简单的html dom-,php,curl,simple-html-dom,Php,Curl,Simple Html Dom,我使用CURL获取这个URL $url = "http://www.juno.co.uk/all/today/?items_per_page=100&show_digital=0&show_tracks=0&show_covers=0"; $c = curl_init(); curl_setopt($c, CURLOPT_URL,"$url"); curl_setopt($c,CURLOPT_POST,true); curl_setopt($c, CURLOPT_CON

我使用CURL获取这个URL

$url = "http://www.juno.co.uk/all/today/?items_per_page=100&show_digital=0&show_tracks=0&show_covers=0";

$c = curl_init();
curl_setopt($c, CURLOPT_URL,"$url");
curl_setopt($c,CURLOPT_POST,true);
curl_setopt($c, CURLOPT_CONNECTTIMEOUT, 20); //give it adequate time
curl_setopt($c, CURLOPT_TIMEOUT, 50);
curl_setopt($c,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($c, CURLOPT_RETURNTRANSFER,1);

if(!$complete = curl_exec($c))
    {
        echo "Failed to curl $url\n";
    }
然后,我尝试使用

$home_page = str_get_html($complete);
这会引发“PHP致命错误:对非对象调用成员函数find()”错误

foreach($home_page->find('tr.row2') as $home_details)
{
      //do stuff
    } 
当我将'items\u per\u page'参数更改为50时,它就会工作。上面的链接是有效的,当我返回$complete时,它将显示页面代码

simple_html_dom在脚本的前面加载并正常工作


我尝试使用file_get_html而不是CURL,结果相同

当您使用var_dump
$home_page
时,您得到了什么?这可能意味着
str_get_html
返回异常,尝试使用
var_dump
返回异常。例如,您的HTML可能无效。您也可以尝试将
file\u get\u HTML
直接与url一起使用(而不使用
curl
),因为我想发出
get
请求而不是
POST
应该会得到相同的结果