OP 24 July, 2024 - 08:20 AM
(This post was last modified: 24 July, 2024 - 08:21 AM by ism52. Edited 1 time in total.)
I needed to collect usernames, emails, and phone numbers from an Instagram page, so I created a scraper. It successfully captured up to 500 leads before the endpoint that retrieves user data was temporarily blocked. After a few hours, the endpoint was unblocked, and I continued scraping data from 10,000 users. By adjusting the "cursor" variable, you can start from where you left off.
Steps:
1 - Install Python 3
2 - Install Pip
3 - pip install InstaGPy
4 - Create folder "Followers"
5 - Edit your main.py
This script is very short and easy to adapt to your needs. Currently, it saves all user data in the "Followers" folder.
Like this:
SO MUCH INFO
If you encounter issues with 2FA, I found a solution from a user on GitHub (or send a pull request with correction):
https://github.com/iSarabjitDhiman/InstaGPy/issues/13
This script really pulls a lot of data. Additionally, the script could theoretically work with multiple Instagram accounts. You just need to assign an IP to each one using a service like LunaProxy.
Thank you and sorry for my English.
Steps:
1 - Install Python 3
2 - Install Pip
3 - pip install InstaGPy
4 - Create folder "Followers"
5 - Edit your main.py
Code:
from instagpy import InstaGPy
import time
import random
import json
insta = InstaGPy()
insta.login('YOUR USERNAME HERE', 'YOUR PASSWORD HERE', show_saved_sessions=False, save_session=True)
followers = []
has_more = True
cursor = 0
while has_more:
try:
response = insta.get_user_friends('PAGE TO SCRAPPER', followers_list=True, end_cursor=cursor, pagination=False)
if response is None:
break
followers_data = response.get('data', [])
for user in followers_data:
if user.get('is_private'):
continue
username = user.get('username')
print("Lendo " + username, " / Cursor: "+str(cursor))
if username:
userinfo = (insta.get_user_data(username))
with open('Followers/'+username+".txt", 'w') as f:
json.dump(userinfo, f)
time.sleep(random.uniform(3, 5))
has_more = response.get('has_next_page', False)
if has_more:
print("Getting more")
cursor = response.get('end_cursor')
time.sleep(random.uniform(1, 5))
except Exception as error:
print(f"Error: {error}")
break
This script is very short and easy to adapt to your needs. Currently, it saves all user data in the "Followers" folder.
Like this:
Code:
[size=xx-small]{
"user": {
"primary_profile_link_type": 1,
"show_fb_link_on_profile": true,
"show_fb_page_link_on_profile": false,
"can_hide_category": true,
"account_type": 2,
"current_catalog_id": null,
"mini_shop_seller_onboarding_status": null,
"account_category": "",
"can_add_fb_group_link_on_profile": false,
"can_use_affiliate_partnership_messaging_as_creator": false,
"can_use_affiliate_partnership_messaging_as_brand": false,
"existing_user_age_collection_enabled": true,
"fbid_v2": 17841413448362155,
"feed_post_reshare_disabled": false,
"full_name": "Loco Motos Seberi",
"has_guides": false,
"has_ig_profile": true,
"has_public_tab_threads": true,
"highlight_reshare_disabled": false,
"include_direct_blacklist_status": true,
"is_direct_roll_call_enabled": true,
"is_eligible_for_meta_verified_links_in_reels": true,
"is_new_to_instagram": false,
"is_parenting_account": false,
"is_private": false,
"is_secondary_account_creation": false,
"pk": 13617240278,
"pk_id": "13617240278",
"profile_type": 0,
"show_account_transparency_details": true,
"show_post_insights_entry_point": true,
"third_party_downloads_enabled": 0,
"is_opal_enabled": false,
"strong_id__": "13617240278",
"biography": "* Loja de pe\u00e7as,acess\u00f3rios e equipamentos Off-Road.\n* Oficina especializada para motos Nacionais e Importadas.",
"external_url": "",
"has_biography_translation": true,
"can_hide_public_contacts": true,
"category": "Entrepreneur",
"should_show_category": true,
"category_id": 1617,
"is_category_tappable": true,
"should_show_public_contacts": true,
"is_eligible_for_smb_support_flow": true,
"is_eligible_for_lead_center": true,
"lead_details_app_id": "com.bloks.www.ig.smb.lead_gen.subpage",
"is_business": true,
"professional_conversion_suggested_account_type": 2,
"direct_messaging": "UNKNOWN",
"fb_page_call_to_action_id": "",
"instagram_location_id": "",
"address_street": "Av.Gal.Flores da Cunha n\u00b0 1111",
"business_contact_method": "CALL",
"city_id": 106398872727063,
"city_name": "Seberi, Rio Grande Do Sul, Brazil",
"contact_phone_number": "+555537461440",
"is_profile_audio_call_enabled": false,
"latitude": -27.4817873,
"longitude": -53.4017931,
"public_email": "[email protected]",
"public_phone_country_code": "55",
"public_phone_number": "5537461440",
"zip": "98380-000",
"displayed_action_button_partner": null,
"smb_delivery_partner": null,
"smb_support_delivery_partner": null,
"displayed_action_button_type": "",
"smb_support_partner": null,
"is_call_to_action_enabled": false,
"num_of_admined_pages": null,
"page_id": 1063845553745618,
"page_name": "Loco Motos Seberi",
"ads_page_id": 1063845553745618,
"ads_page_name": "Loco Motos Seberi",
"shopping_post_onboard_nux_type": null,
"ads_incentive_expiration_date": null,
"account_badges": [],
"additional_business_addresses": [],
"auto_expand_chaining": null,
"bio_links": [],
"birthday_today_visibility_for_viewer": "NOT_VISIBLE",
"can_use_branded_content_discovery_as_brand": false,
"can_use_branded_content_discovery_as_creator": false,
"can_use_paid_partnership_messaging_as_creator": false,
"chaining_upsell_cards": [],
"fan_club_info": {
"autosave_to_exclusive_highlight": null,
"connected_member_count": null,
"fan_club_id": null,
"fan_club_name": null,
"has_enough_subscribers_for_ssc": null,
"is_fan_club_gifting_eligible": null,
"is_fan_club_referral_eligible": null,
"subscriber_count": null,
"fan_consideration_page_revamp_eligiblity": null
},
"follow_friction_type": 0,
"follower_count": 2986,
"following_count": 1460,
"has_anonymous_profile_picture": false,
"has_chaining": true,
"has_exclusive_feed_content": false,
"has_fan_club_subscriptions": false,
"has_highlight_reels": true,
"has_igtv_series": false,
"has_music_on_profile": false,
"has_private_collections": false,
"has_videos": true,
"hd_profile_pic_url_info": {
"height": 1080,
"url": "https://instagram.fbnu9-1.fna.fbcdn.net/v/t51.2885-19/358213828_960974538471339_1305071095655786441_n.jpg?_nc_ht=instagram.fbnu9-1.fna.fbcdn.net&_nc_cat=103&_nc_ohc=6W18Ziieze4Q7kNvgFeHIO9&edm=AEF8tYYBAAAA&ccb=7-5&oh=00_AYDdj4W-Rnywh9i0QuzO58R9ZES-rizL5NsVlbGQUp16ZA&oe=66A62AB3&_nc_sid=1e20d2",
"width": 1080
},
"hd_profile_pic_versions": [
{
"height": 320,
"url": "https://instagram.fbnu9-1.fna.fbcdn.net/v/t51.2885-19/358213828_960974538471339_1305071095655786441_n.jpg?stp=dst-jpg_s320x320&_nc_ht=instagram.fbnu9-1.fna.fbcdn.net&_nc_cat=103&_nc_ohc=6W18Ziieze4Q7kNvgFeHIO9&edm=AEF8tYYBAAAA&ccb=7-5&oh=00_AYA6txA9P-fooE00lof0vV5sDTq04zQSdXqaTontpItHTA&oe=66A62AB3&_nc_sid=1e20d2",
"width": 320
},
{
"height": 640,
"url": "https://instagram.fbnu9-1.fna.fbcdn.net/v/t51.2885-19/358213828_960974538471339_1305071095655786441_n.jpg?stp=dst-jpg_s640x640&_nc_ht=instagram.fbnu9-1.fna.fbcdn.net&_nc_cat=103&_nc_ohc=6W18Ziieze4Q7kNvgFeHIO9&edm=AEF8tYYBAAAA&ccb=7-5&oh=00_AYAd-aGVT2YMRJnZFAFolLGBHAfncfQW5oa9RkrqZZUtug&oe=66A62AB3&_nc_sid=1e20d2",
"width": 640
}
],
"highlights_tray_type": "DEFAULT",
"interop_messaging_user_fbid": 118238732899066,
"is_bestie": false,
"is_creator_agent_enabled": false,
"is_eligible_for_meta_verified_enhanced_link_sheet": false,
"is_eligible_for_meta_verified_enhanced_link_sheet_consumption": false,
"is_eligible_for_meta_verified_multiple_addresses_creation": false,
"is_eligible_for_meta_verified_multiple_addresses_consumption": false,
"is_eligible_for_meta_verified_related_accounts": false,
"meta_verified_related_accounts_count": 0,
"is_meta_verified_related_accounts_display_enabled": false,
"is_eligible_for_meta_verified_label": true,
"is_favorite": false,
"is_in_canada": false,
"is_interest_account": true,
"is_memorialized": false,
"is_potential_business": false,
"is_regulated_news_in_viewer_location": false,
"is_remix_setting_enabled_for_posts": true,
"is_remix_setting_enabled_for_reels": true,
"is_profile_broadcast_sharing_enabled": true,
"is_regulated_c18": false,
"is_stories_teaser_muted": false,
"is_recon_ad_cta_on_profile_eligible_with_viewer": true,
"is_supervision_features_enabled": false,
"is_verified": false,
"is_whatsapp_linked": true,
"latest_besties_reel_media": 0,
"latest_reel_media": 1721744859,
"linked_fb_info": {
"linked_fb_user": {
"id": "",
"name": "Loco Motos Seberi",
"is_valid": true,
"fb_account_creation_time": null,
"link_time": null,
"profile_url": "https://www.facebook.com/profile.php?id=100003928183940"
}
},
"live_subscription_status": "default",
"media_count": 883,
"mutual_followers_count": 0,
"nametag": {
"background_image_url": "",
"is_background_image_blurred": true
},
"open_external_url_with_in_app_browser": true,
"pinned_channels_info": {
"pinned_channels_list": [],
"has_public_channels": false
},
"profile_context": "",
"profile_context_facepile_users": [],
"profile_context_links_with_user_ids": [],
"profile_pic_id": "3140177309072522993_13617240278",
"profile_pic_url": "https://instagram.fbnu9-1.fna.fbcdn.net/v/t51.2885-19/358213828_960974538471339_1305071095655786441_n.jpg?stp=dst-jpg_e0_s150x150&_nc_ht=instagram.fbnu9-1.fna.fbcdn.net&_nc_cat=103&_nc_ohc=6W18Ziieze4Q7kNvgFeHIO9&edm=AEF8tYYBAAAA&ccb=7-5&oh=00_AYAbhzd4vP7bnAvaFDnq_TKjW3lZnpVwKrcHf9T3hjRC1g&oe=66A62AB3&_nc_sid=1e20d2",
"pronouns": [],
"recon_features": {
"enable_recon_cta": true
},
"relevant_news_regulation_locations": [],
"remove_message_entrypoint": false,
"show_schools_badge": null,
"text_app_last_visited_time": null,
"eligible_for_text_app_activation_badge": false,
"total_ar_effects": 0,
"total_clips_count": 1,
"total_igtv_videos": 5,
"transparency_product_enabled": false,
"username": "locomotos.seberi_rs",
"whatsapp_number": "",
"is_profile_picture_expansion_enabled": true,
"recs_from_friends": {
"enable_recs_from_friends": false,
"recs_from_friends_entry_point_type": "banner"
},
"adjusted_banners_order": [],
"is_eligible_for_request_message": false,
"is_open_to_collab": false,
"has_ever_selected_topics": false,
"is_oregon_custom_gender_consented": false
},
"status": "ok"
}[/size]
SO MUCH INFO
If you encounter issues with 2FA, I found a solution from a user on GitHub (or send a pull request with correction):
https://github.com/iSarabjitDhiman/InstaGPy/issues/13
This script really pulls a lot of data. Additionally, the script could theoretically work with multiple Instagram accounts. You just need to assign an IP to each one using a service like LunaProxy.
Thank you and sorry for my English.
Virustotal link https://www.virustotal.com/gui/file/25fb47ab34277f02373c2e7b1db05671f45b82fb894c4c7b57d6de0c56c69a5c/community