Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* filename : scrap.php
- * author : Deepanshu Thakur
- * e-mail : deepanshu2017@gmail.com , deepanshu2017@hotmail.com
- * description : This file takes a instagram userid and scrap all the
- * followers of that user and write into file.
- */
- require '../src/Instagram.php';
- ini_set('memory_limit', '-1');
- define('SLEEP_TIME',1);
- define('TARGET_USER_ID',432464344);
- /////// CONFIG ///////
- $username = 'USERNAME';
- $password = 'PASSWORD';
- $debug = false;
- $i = new Instagram($username, $password, $debug);
- $myfile = fopen("FILE_NAME.txt", "w") or die("Unable to open file");
- try {
- // Login to my account.
- $i->login();
- // Get followers list. Instagram will return maximum of 200 users in a
- // single request.
- $var = $i->getUserFollowers(TARGET_USER_ID);
- do {
- // Take the desired field from the output.
- sleep(SLEEP_TIME);
- $results = $var['users'];
- foreach($results as $result) {
- $username = $result['username'];
- $username = $username . "\n";
- fwrite($myfile, $username);
- }
- // While request have next page link continue with loop else break.
- if (in_array('next_max_id', $var)) {
- $next_max_id = $var['next_max_id'];
- $var = $i->getUserFollowers(TARGET_USER_ID, $next_max_id);
- } else {
- break;
- }
- } while (true);
- } catch (InstagramException $e) {
- $e->getMessage();
- fclose($myfile);
- exit();
- }
- fclose($myfile);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement