Advertisement
Guest User

Untitled

a guest
Oct 13th, 2018
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.59 KB | None | 0 0
  1. <?php
  2.  
  3. $content = file_get_contents(__DIR__ . '/accounts');
  4. $accounts = explode("\n", $content);
  5. $accounts = array_filter(array_unique($accounts));
  6. if (empty($accounts)) {
  7.     echo("Add accounts to file  'accounts', each in a new line.\n");
  8. }
  9.  
  10. @mkdir(__DIR__ . '/res');
  11. @chmod(__DIR__ . '/res', 0777);
  12.  
  13. foreach ($accounts as $account) {
  14.     if (download($account)) {
  15.         echo "$account - OK!\n";
  16.     } else {
  17.         echo "$account - ERR!\n";
  18.     }
  19.     //sleep(1); // in seconds
  20. }
  21.  
  22. function download($username)
  23. {
  24.     $url = "https://www.instagram.com/{$username}/";
  25.     $ch = curl_init($url);
  26.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  27.     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  28.     //curl_setopt($ch, CURLOPT_HEADER, true);
  29.     //curl_setopt($ch, CURLOPT_NOBODY, true);
  30.     curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36');
  31.     $content = curl_exec($ch);
  32.     //print_r(curl_getinfo($ch));
  33.     //print_r($content);
  34.     if (curl_getinfo($ch, CURLINFO_HTTP_CODE) === 404) {
  35.         return false;
  36.     }
  37.  
  38.     preg_match('/\_sharedData \= (.*?)\;\<\/script\>/s', $content, $matches);
  39.     $arr = json_decode($matches['1'], true, 512, JSON_BIGINT_AS_STRING);
  40.     $url = $arr['entry_data']['ProfilePage']['0']['graphql']['user']['profile_pic_url_hd'];
  41.  
  42.     if (($image = file_get_contents($url))) {
  43.         return file_put_contents(sprintf('%s%s%s_%s', __DIR__ . '/res', DIRECTORY_SEPARATOR, $username, basename($url)), $image);
  44.     }
  45.  
  46.  
  47.     return false;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement