Our platform is often used by growth hackers for lead generation in social media networks. One such use case is building a list of Instagram followers from interestingprofiles. Today we placed one such robot into our portal‘s demo space for anyone to use. Robot is only 30 lines of Javascript code and works quite fast. We tested it with IBM’s Instagram which has 78k followers and it took only 14 minutes to scrape them.

instagram_robot

How to use this robot:

  1. Login to Web Robots portal on Chrome browser.
  2. Make sure you have Web Robots Chrome extension to run the robot.
  3. Open robot instagram_followers in our extension.
  4. Make sure you are logged in on Instagram website.
  5. Modify start URL to the desired Instagram profile (example: https://www.instagram.com/ibm) and click Run.
  6. When robot is finished data will be available on portal in CSV and JSON formats.

Remember, this robot is placed in Demo space, which means it can be modified by anyone. In case someone messes up the code, you can restore it from code below. Just paste it into extension’s editor:

// Must be logged in
// Start URL above must be target Instagram profile. Example: https://www.instagram.com/ibm/
 
steps.start = function(req) {
 
    var user_id = $("script:contains(profilePage_)").text().split('profilePage_')[1].split('"')[0];
 
    if (!req) {
        req = "q=ig_user(" + user_id + ")+%7B%0A++followed_by.first(20)+%7B%0A++++count%2C%0A++++page_info+%7B%0A++++++end_cursor%2C%0A++++++has_next_page%0A++++%7D%2C%0A++++nodes+%7B%0A++++++id%2C%0A++++++is_verified%2C%0A++++++followed_by_viewer%2C%0A++++++requested_by_viewer%2C%0A++++++full_name%2C%0A++++++profile_pic_url%2C%0A++++++username%0A++++%7D%0A++%7D%0A%7D%0A&ref=relationships%3A%3Afollow_list";
    }
 
    var token = $("script:contains(csrf_token)").text().split('"csrf_token": "').pop().split('"').shift();
 
    $.ajax({
        url: "https://www.instagram.com/query/",
        headers: {
            'x-instagram-ajax': '1',
            "x-csrftoken": token
        },
        method: 'POST',
        data: req,
        success: function(data) {
 
            emit("Followers", data.followed_by.nodes);
 
            if (data.followed_by.page_info.has_next_page) {
                var next_req = "q=ig_user(" + user_id + ")+%7B%0A++followed_by.after(" + data.followed_by.page_info.end_cursor + "%2C+20)+%7B%0A++++count%2C%0A++++page_info+%7B%0A++++++end_cursor%2C%0A++++++has_next_page%0A++++%7D%2C%0A++++nodes+%7B%0A++++++id%2C%0A++++++is_verified%2C%0A++++++followed_by_viewer%2C%0A++++++requested_by_viewer%2C%0A++++++full_name%2C%0A++++++profile_pic_url%2C%0A++++++username%0A++++%7D%0A++%7D%0A%7D%0A&ref=relationships%3A%3Afollow_list";
                next("", "start", next_req);
            }
 
            done(1000);
        }
    });
};