php script that print all src of any image in a splider site
I'm using SimpleHTMLDOM to retrive all uri of all images of a site, but during the execution i'm g开发者_运维技巧etting a memory usage error, how to solve?
$count = 0;
$last = 1721;
include('simple_html_dom.php');
while ( $count <= $last) {
$html = file_get_html('http://myuri/?from='.$count);
// find all image inside post div
foreach($html->find('div.itemPost img') as $e) {
echo $e->src . '<br>';
}
}
this is the error:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 35 bytes) in /home/peppo1616/public_html/script/simple_html_dom.php on line 1189
Call the destructor after looping through img tags and assign null
to $html
to clear some memory.
while ( $count <= $last) {
$html = file_get_html('http://myuri/?from='.$count);
// find all image inside post div
foreach($html->find('div.itemPost img') as $e) {
echo $e->src . '<br>';
}
$html->clear();
$html = null;
}
On a side note, I don't see any incrementation of $count
, you may end with infinite loop.
精彩评论