zero-perfoliate
zero-perfoliate

Author Topic: need help in fetching images  (Read 1366 times)

Offline ultratut

  • New PHP Members
  • Posts: 2
  • Karma: +0/-0
need help in fetching images
« on: February 23, 2008, 01:22:52 AM »
<?php
function extract_url($main_url){

    $cek_url = parse_url($main_url);
    $prefix_url = $cek_url['scheme'].'://'.$cek_url['host'];

    $f = fopen($main_url,"r");
    $inputStream = fread($f,65535);
    fclose($f);
    if (preg_match_all("/<img.*? src=\"(.*?)\".*?>/i",$inputStream,$matches)) {
        foreach($matches[1] as $link){
            if(!eregi('mailto:|javascript:|ymsgr:',$link)){
                if(eregi("http://",$link)){
                    $url = $link;
                }
                else{
                    $url = $prefix_url.'/'.$link;
                }
                if(eregi('PHPSESSID',$url)){
                    $url = explode("PHPSESSID",$url);
                    $url = substr($url[0],0,-1);
                }
                $output[] = $url;
            }
        }
    }
    return $output;
}
?>




<html>
<head>
</head>
<body>
<?php

$check=extract_url("http://www.example.com");
for($i=0;$check[$i]!='';$i++)
{
echo '<img src="'.$check[$i].'"/>

';
}



?>.
</body>
</html>


I m trying to fetch out all the images of the given url
but this code  fetches the only some images . i need all the images so plz try to find out the error.

 

zero-perfoliate