Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- #-*- coding: utf-8 -*-
- # MADE BY V3N0M
- import requests, json, datetime, getpass
- import urllib2 as rq
- from urllib2 import HTTPError
- import urllib as http_parser
- def get_csrf():
- global csrf_token
- print "[*] Fetching CSRF Token..."
- try:
- opener = rq.build_opener(rq.HTTPHandler(), rq.HTTPSHandler())
- opener.addheaders = [('User-agent', 'Mozilla/5.0')]
- rq.install_opener(opener)
- request = rq.Request('https://www.instagram.com/')
- try:
- headers = rq.urlopen(request).info().headers
- except:
- pass
- for header in headers:
- if header.find('csrftoken') != -1:
- csrf_token = header.partition(';')[0].partition('=')[2]
- print "[+] CSRF Token Acquired: "+csrf_token+"\n"
- except Exception as e:
- print "[!] Failed to acquire CSRF Token"
- print "Error: "+str(e)
- def login():
- print "Logging in as?"
- username = str(raw_input("[*] Username: "))
- if "@" in username:
- username = username.strip("@")
- password = getpass.getpass("[*] Password: ")
- print str(username)+":"+str(password)
- def main():
- banner = """
- __ ___ ____ __ __ __ ____ _ _
- ( )/ __)(_ _)/ \ / \ ( ) ( _ \( \/ )
- )(( (_ \ )( ( O )( O )/ (_/\ _ ) __/ ) /
- (__)\___/ (__) \__/ \__/ \____/(_)(__) (__/
- """
- print "Authentication of user is needed for an upcoming update."
- while True:
- try:
- askForLogin = str(raw_input("[*] Log-In? [Y/N]: "))
- askForLogin = askForLogin.upper()
- if "Y" in askForLogin:
- get_csrf()
- login()
- break
- elif "N" in askForLogin:
- break
- else:
- print "Please input Y/N!"
- except KeyboardInterrupt:
- print "\n[*] ^C Detected...\n[*] Exiting..."
- exit(0)
- except Exception as err:
- print "Oops, something went wrong!"
- print "\n"+str(err)
- try:
- print "\nInput user you want to extract data for."
- usr = str(raw_input("[*] User: "))
- if "@" in usr:
- usr = usr.strip("@")
- req = requests.get("https://www.instagram.com/"+usr+"/?__a=1")
- statusCode = req.status_code
- jsonData = req.text
- parseData = json.loads(jsonData)
- except KeyboardInterrupt:
- print "\n[*] ^C Detected...\n[*] Exiting..."
- exit(0)
- except Exception as e:
- while True:
- print "Oops, something went wrong!\nThis is probably caused by the fact that the user doesn't exist."
- print "\nMake sure you typed the user correctly!"
- printErr = str(raw_input("Print Error Info? [Y/N]: "))
- printErr = printErr.upper()
- if "Y" in printErr:
- print "Error info: "+str(e)
- exit(0)
- elif "N" in printErr:
- exit(0)
- else:
- print "Please input Y/N!"
- print "Save to file/show to stdout?"
- saveOption = str(raw_input("File [F]/STDOUT [S]: "))
- saveOption = saveOption.upper()
- if "F" in saveOption:
- print "[*] Saving to file..."
- f = open(str(usr)+"_"+str(datetime.date.today())+".txt", "w")
- f.write(banner+"\n")
- f.write("User: "+usr+"\n")
- f.write("UserID: "+str(parseData['graphql']['user']['id'])+"\n")
- f.write("Name: "+str(parseData['graphql']['user']['full_name'])+"\n")
- f.write("Follower Count: "+str(parseData['graphql']['user']['edge_followed_by']['count'])+"\n")
- f.write("Following Count: "+str(parseData['graphql']['user']['edge_follow']['count'])+"\n")
- f.write("Biography: "+str(parseData['graphql']['user']['biography'])+"\n")
- f.write("External URL: "+str(parseData['graphql']['user']['external_url'])+"\n")
- f.write("Verified: "+str(parseData['graphql']['user']['is_verified'])+"\n")
- f.write("PFP Link: "+str(parseData['graphql']['user']['profile_pic_url_hd'])+"\n")
- f.write("No. of Posts: "+str(parseData['graphql']['user']['edge_owner_to_timeline_media']['count']))
- f.close()
- print "[+] Saved as: " +str(usr)+"_"+str(datetime.date.today())+".txt"
- elif "S" in saveOption:
- print banner+"\n"
- print "User: "+usr
- print "UserID: " + str(parseData['graphql']['user']['id'])
- print "Name: " + str(parseData['graphql']['user']['full_name'])
- print "Follower Count: " + str(parseData['graphql']['user']['edge_followed_by']['count'])
- print "Following Count: " + str(parseData['graphql']['user']['edge_follow']['count'])
- print "Biography: " + str(parseData['graphql']['user']['biography'])
- print "External URL: " + str(parseData['graphql']['user']['external_url'])
- print "Verified: " + str(parseData['graphql']['user']['is_verified'])
- print "PFP Link: " + str(parseData['graphql']['user']['profile_pic_url_hd'])
- print "No. of Posts: " + str(parseData['graphql']['user']['edge_owner_to_timeline_media']['count'])
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement