Jump to content

Image link counting & listing from a remote page


Ozz

Recommended Posts

I need to count and list image links from a remote page.
I tried this code:
[CODE]
$url = "http://www.siteurl.com/page.html";
$file = fopen ("$url", "r");
if (!($file))
{
echo "Not exist!";
exit;
}
while (!feof ($file)) {
  $line = fgets ($file, 1024);
  if (eregi ("HREF=\"(.*).jpg\">", $line, $out)) {
      $image = $out[1].".jpg";
      $pos = strpos($image, "http://");
if ($pos === false) {
  $image_url = dirname($url)."/".$image;
}
     
echo $image_url;
}
}
[/CODE]

But it's not working stable on different sites especially only works if the image link codes are on one line.

Can anyone suggest any code for listing image links?

Thanks in advance.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.