I wrote a image crawler with simple_html_dom library, I used this code to fetch all images in a web site ;
include 'simple_html_dom.php';
$img_array = array();
if (isset($_POST['url'])) {
$url = $_POST['url'];
$html = file_get_html($url);
echo $html->getElementByTagName('title')->innertext();
foreach ($html->find('a') as $a) {
if (strpos($a->href, $url) !== FALSE) // only images from this site
{
//
// find_images($a->href);
$imgs = file_get_html($a->href);
foreach ($imgs->find('img') as $img) {
if(!in_array($img->src, $img_array))
{
echo '<img src="' .$img->src. '" class="thumb">';
$img_array[] = $img->src;
}
}
echo '<hr>';
}
}
}
but whene i execute this code i get Fatal error: Allowed memory size of 209715200 bytes exhausted (tried to allocate 71 bytes) in /home/iphotosh/public_html/test/simple_html_dom.php on line 122
test and demo : test.iphotoshop.ir
how to fix this error or how to opti,ize this code for fetch all images from a web site?
ini_set('memory_limit', '500M');but when images in web site to many again get this error