Advertisement
Feelingfree

Get picture url

Mar 19th, 2014
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.75 KB | None | 0 0
  1. <?php
  2. header("Content-Type:text/plain");
  3. set_time_limit (0);
  4. $dir = dirname(__FILE__);
  5. $data = file_get_contents("$dir/full_html.htm");
  6.  
  7. // regex find url
  8. preg_match_all('@https://fbcdn-sphotos-[a-z]+-a.akamaihd.net/hphotos-ak-[a-z0-9]+/t1.0-9/p417x417/[0-9]+_[0-9]+_[0-9]+_[a-z]+.jpg@si',$data,$url);
  9. $url = $url['0'];
  10.  
  11.  
  12. $i = 1;
  13.  
  14. foreach ($url as $key => $vaule) {
  15.    
  16.     $vaule = str_replace("/p417x417/", "/", $vaule); // make it to link full resulotion
  17.     download_img($vaule,$i);
  18.     $i++;
  19. }
  20.  
  21.  
  22. function download_img($url,$num) { // download funcion
  23.        
  24.     $img = imagecreatefromjpeg($url);
  25.     $path = "downloads/$num.jpg";
  26.     imagejpeg($img, $path);
  27.    
  28.     echo "Downloaded $num \n";
  29. }
  30.  
  31.  
  32. die(); // get exit code 0
  33.  
  34.  
  35. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement