Php 简单的html dom:Can';无法从大型网站接收图像?
我使用simple_html_dom.php从url获取所有图像(就像pinterest那样) }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
对于很多网站,我都会统计网站上有多少张图片。但例如,对于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);