Jump to content

help with image grabber


scarhand

Recommended Posts

alright this script works for the most part, except when you enter an URL such as news.msn.com, will not show results

 

also does not show results for some other sites

 

heres the code:

 

<?php

  if (substr($url, -1) != '/')
    $ddurl = "$url/";
  
  $ddcontent = file_get_contents($ddurl);
  
  preg_match_all("/\< *[img][^\>]*[src] *= *[\"\']{0,1}([^\"\'\ >]*)/i", $ddcontent, $ddmatches);
  
  foreach (array_unique($ddmatches[1]) as $ddimg)
  {
    if ($ddimg[0] == '/')
      $ddimg = substr($ddimg, 1);
  
    if (!preg_match("|^http://|i", $ddimg) && !preg_match("|^https://|i", $ddimg))
      $ddimg = "$ddurl$ddimg";

    $ddmysock = getimagesize($ddimg);
    $ddwidth = $ddmysock[0];
    $ddheight = $ddmysock[1];

    if ($ddwidth > 150 || $ddheight > 150)
    {
      if ($ddwidth > $hddeight)
        $ddpercentage = (150 / $ddwidth); 
      else
        $ddpercentage = (150 / $ddheight);
        
      $ddwidth = round($ddwidth * $ddpercentage); 
      $ddheight = round($ddheight * $ddpercentage); 
    }

    $ddimgtag = "<img src=\"$ddimg\" width=\"$ddwidth\" height=\"$ddheight\">";
    
    $ddext = substr($ddimg, -4);
    
    if ($ddext == '.gif' || $ddext == '.jpg' || $ddext == '.png')
      $newimages[] = array('url' => $ddimg, 'img_tag' => $ddimgtag);
  }

?>

 

any suggestions?

Link to comment
https://forums.phpfreaks.com/topic/133277-help-with-image-grabber/
Share on other sites

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.