Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/284.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
使用simple_html_dom.php从不同的URL中抓取大量数据_Php_Html_Performance_Dom - Fatal编程技术网

使用simple_html_dom.php从不同的URL中抓取大量数据

使用simple_html_dom.php从不同的URL中抓取大量数据,php,html,performance,dom,Php,Html,Performance,Dom,我基本上想做的就是这样: ini_set('memory_limit', '128M'); 到目前为止,我已经完成了所有工作,但现在我遇到了以下错误,因为我刮取了许多站点(目前为6个,我最多需要25个站点): 我是一名php新手=/…那么,我如何才能一步一步地“序列化”刮取过程,使我的内存不被放弃呢?:-) 代码示例: // Include the library include('simple_html_dom.php'); // retrieve and find contents $h

我基本上想做的就是这样:

ini_set('memory_limit', '128M');
到目前为止,我已经完成了所有工作,但现在我遇到了以下错误,因为我刮取了许多站点(目前为6个,我最多需要25个站点):

我是一名php新手=/…那么,我如何才能一步一步地“序列化”刮取过程,使我的内存不被放弃呢?:-)

代码示例:

// Include the library
include('simple_html_dom.php');

// retrieve and find contents
$html0 = file_get_html('http://www.site.com/');
foreach($html0->find('#id') as $aktuelle_spiele);

file_put_contents("cache/cache0.html",$aktuelle_spiele);

非常感谢您的帮助

在php.ini中,更改此行:

内存限制=32M

关于这一点:

内存限制=256M//或其他更大的值

或者在每个使用simple_html_dom的php脚本的开头添加以下代码:

ini_set('memory_limit', '128M'); //or a greater value

您可以在脚本开始时运行内存增加

像这样:

ini_set('memory_limit', '128M');

内存上限…看起来你只有32MB的内存limit@ThomasVeit,可以在脚本开始时运行内存增加。像这样:ini_set('memory_limit','128M')mhh,我的主机不允许超过32M的内存。。。有人有别的办法来减少我的脚本记忆吗?@LuigiSiri,哇,非常感谢你!这很有魅力!:)我认为您有自己的服务器……您可以添加@Luigi建议的行和每个使用简单html dom的脚本的开头php@ThomasVeit. 我粘贴了我的评论作为回答。对不起,罗伯特+1.