From a8e20300cc13a926eda3dd28740793fb072c731d Mon Sep 17 00:00:00 2001 From: Aravindha1234u Date: Thu, 1 Oct 2020 21:43:04 +0530 Subject: [PATCH] Instagram Scraper using GraphQL Endpoint --- Web-Scraping/aravindha1234u/README.md | 7 ++++++ Web-Scraping/aravindha1234u/Scraper.py | 32 ++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 Web-Scraping/aravindha1234u/README.md create mode 100644 Web-Scraping/aravindha1234u/Scraper.py diff --git a/Web-Scraping/aravindha1234u/README.md b/Web-Scraping/aravindha1234u/README.md new file mode 100644 index 0000000..92ea6a3 --- /dev/null +++ b/Web-Scraping/aravindha1234u/README.md @@ -0,0 +1,7 @@ +# Instagram Scraper with GraphQL Endpoint + +This is python simple script to scrape maximum public infomation of account with username and it does not have any dependency other than inbuilt python modules. + +## How to Use: + +`Python3 Scraper.py ` diff --git a/Web-Scraping/aravindha1234u/Scraper.py b/Web-Scraping/aravindha1234u/Scraper.py new file mode 100644 index 0000000..50ba9b4 --- /dev/null +++ b/Web-Scraping/aravindha1234u/Scraper.py @@ -0,0 +1,32 @@ +import requests +import sys + +def Instagram(username): + r = requests.get("https://www.instagram.com/"+ username +"/?__a=1") + if r.status_code == 200: + res = r.json()['graphql']['user'] + print("\nUsername: " + res['username']) + print("Full Name: "+res['full_name']) + print("Biograph: " + res['biography']) + print("URL: "+ str(res['external_url'])) + print("Followers: "+str(res['edge_followed_by']['count'])) + print("Following: "+str(res['edge_follow']['count'])) + print("has_channel: "+str(res['has_channel'])) + print("Business Account: "+str(res["is_business_account"])) + if res['is_business_account']: + print("Business Category: "+str(res['business_category_name'])) + print("category_enum: "+str(res['category_enum'])) + print("Joined Recently: "+str(res['is_joined_recently'])) + print("Private Account: "+str(res['is_private'])) + print("Verified: "+str(res['is_verified'])) + print("Facebook Account: "+str(res['connected_fb_page'])) + print("Profile Picture HD: " + res['profile_pic_url_hd']) + elif r.status_code == 404: + print("Error: Profile Not Found") + else: + print("Error: Something Went Wrong") + +if len(sys.argv) == 1 or sys.argv[1] =="-h": + print("Usage: python3 Scraper.py ") +else: + Instagram(sys.argv[1])