Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/230.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 简单的html dom:Can';无法从大型网站接收图像?_Php_Simple Html Dom - Fatal编程技术网

Php 简单的html dom:Can';无法从大型网站接收图像?

Php 简单的html dom:Can';无法从大型网站接收图像?,php,simple-html-dom,Php,Simple Html Dom,我使用simple_html_dom.php从url获取所有图像(就像pinterest那样) } 对于很多网站,我都会统计网站上有多少张图片。但例如,对于pinterest.com网站,我收到以下错误: 警告:文件获取内容(http://www.pinterest.com)[function.file get contents]:无法打开流:第70行的/home/vyrxkian/domains/bblabla/include/simple\u html\u dom.php中的连接超时 失败0

我使用simple_html_dom.php从url获取所有图像(就像pinterest那样)

}


对于很多网站,我都会统计网站上有多少张图片。但例如,对于pinterest.com网站,我收到以下错误:

警告:文件获取内容(http://www.pinterest.com)[function.file get contents]:无法打开流:第70行的/home/vyrxkian/domains/bblabla/include/simple\u html\u dom.php中的连接超时
失败0
当我进一步指定错误时,我得到以下结果:

警告:文件获取内容(http://www.pinterest.com)[function.file get contents]:无法打开流:第70行的/home/vyrxkian/domains/bblabla/include/simple\u html\u dom.php中的连接超时
致命错误:在第30行的/home/vyrxkian/domains/bblablabla.php中对非对象调用成员函数find()

如何预告此错误并读取例如pinterest.com

您可以使用CURL库:

$url =  $_POST['form_url'];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url); // set url to post to
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
curl_setopt($ch, CURLOPT_TIMEOUT, 7); 
$resultHtml = curl_exec($ch); // run the whole process
curl_close($ch);

$html = new simple_html_dom();
$html->load($resultHtml);

我收到以下错误:警告:curl_setopt()[function.curl setopt]:如果启用了安全模式或设置了open_basedir,则无法激活CURLOPT_FOLLOWLOCATION,当我var_转储$html时,我会得到一个输出,但它看起来不完整。我在那里做了一个示例,您可以看到他可以刮取很多站点,但比如说他不想刮的pinterest。我不知道为什么,因为函数正在工作当我使用curl时,比如上面的例子,我不能再刮我自己的站点()。当我不使用curl时,我可以刮这个站点。非常奇怪的问题。。。。。
$url =  $_POST['form_url'];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url); // set url to post to
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
curl_setopt($ch, CURLOPT_TIMEOUT, 7); 
$resultHtml = curl_exec($ch); // run the whole process
curl_close($ch);

$html = new simple_html_dom();
$html->load($resultHtml);