我基本上想要做到这样的事情: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);
非常感谢您的帮助!
答案 0 :(得分:3)
在你的php.ini中,改变这一行:
memory_limit = 32M
有了这个:
memory_limit = 256M //或其他更大的值
或者在每个使用simple_html_dom的php脚本的开头添加这段代码:
ini_set('memory_limit', '128M'); //or a greater value
答案 1 :(得分:0)
您可以在脚本开头增加内存。
像这样:
ini_set('memory_limit', '128M');