Advertisement
Guest User

Untitled

a guest
Mar 6th, 2019
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.71 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.  
  11. foreach($accounts as $account){
  12.         echo "$account - ".er($account)."\n";
  13.     sleep(1); // in seconds
  14. }
  15.  
  16. function er($username){
  17.     $url = "https://www.instagram.com/{$username}/";
  18.     $ch = curl_init($url);
  19.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  20.     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  21.     //curl_setopt($ch, CURLOPT_HEADER, true);
  22.     //curl_setopt($ch, CURLOPT_NOBODY, true);
  23.     curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36');
  24.     $content = curl_exec($ch);
  25.     //print_r(curl_getinfo($ch));
  26.     //print_r($c);
  27.     if(curl_getinfo($ch, CURLINFO_HTTP_CODE) === 404){
  28.         return 'ERR!';
  29.     }
  30.    
  31.     preg_match('/\_sharedData \= (.*?)\;\<\/script\>/s', $content, $matches);
  32.     $res = json_decode($matches['1'], true);
  33.    
  34.     $followedBy = $res['entry_data']['ProfilePage']['0']['graphql']['user']['edge_followed_by']['count'];
  35.  
  36.     $posts = $res['entry_data']['ProfilePage']['0']['graphql']['user']['edge_owner_to_timeline_media']['edges'];
  37.     $likes = [];
  38.     $comments = [];
  39.  
  40.     foreach ($posts as $post) {
  41.         $likes[] = $post['node']['edge_media_preview_like']['count'];
  42.         $comments[] = $post['node']['edge_media_to_comment']['count'];
  43.     }
  44.  
  45.     if ($likes) {
  46.         $er = (array_sum($likes) + array_sum($comments))/ count($likes) / $followedBy;
  47.         // raw
  48.         // return $er;
  49.        
  50.         // formated
  51.         return number_format($er * 100, 2).'%';
  52.     }
  53.  
  54.     return 'ERR!';
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement