1

我基本上想做这样的事情:Simple Html DOM Caching

到目前为止,我一切正常,但现在我收到以下错误,因为我抓取了许多网站(目前为 6 个,我最多需要 25 个网站):

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 39 bytes)

我是 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);

非常感谢您的帮助!

4

2 回答 2

3

在您的 php.ini 中,更改此行:

memory_limit = 32M

有了这个:

memory_limit = 256M //或另一个更大的值

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

ini_set('memory_limit', '128M'); //or a greater value
于 2013-05-17T16:00:43.020 回答
0

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

像这样:

ini_set('memory_limit', '128M');
于 2013-05-17T18:01:54.587 回答