Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $content = file_get_contents(__DIR__.'/accounts');
- $accounts = explode("\n", $content);
- $accounts = array_filter(array_unique($accounts));
- if(empty($accounts)){
- echo("Add accounts to file 'accounts', each in a new line.\n");
- }
- foreach($accounts as $account){
- echo "$account - ".er($account)."\n";
- sleep(1); // in seconds
- }
- function er($username){
- $url = "https://www.instagram.com/{$username}/";
- $ch = curl_init($url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- //curl_setopt($ch, CURLOPT_HEADER, true);
- //curl_setopt($ch, CURLOPT_NOBODY, true);
- 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');
- $content = curl_exec($ch);
- //print_r(curl_getinfo($ch));
- //print_r($c);
- if(curl_getinfo($ch, CURLINFO_HTTP_CODE) === 404){
- return 'ERR!';
- }
- preg_match('/\_sharedData \= (.*?)\;\<\/script\>/s', $content, $matches);
- $res = json_decode($matches['1'], true);
- $followedBy = $res['entry_data']['ProfilePage']['0']['graphql']['user']['edge_followed_by']['count'];
- $posts = $res['entry_data']['ProfilePage']['0']['graphql']['user']['edge_owner_to_timeline_media']['edges'];
- $likes = [];
- $comments = [];
- foreach ($posts as $post) {
- $likes[] = $post['node']['edge_media_preview_like']['count'];
- $comments[] = $post['node']['edge_media_to_comment']['count'];
- }
- if ($likes) {
- $er = (array_sum($likes) + array_sum($comments))/ count($likes) / $followedBy;
- // raw
- // return $er;
- // formated
- return number_format($er * 100, 2).'%';
- }
- return 'ERR!';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement