def dowload_data(self, username, threshold): instagram = Instagram() medias = instagram.get_medias(username, threshold) dirName = "" for media in medias: media = instagram.get_media_by_url(media.link) image = Image(media) dirName = image.saveImage() return dirName
def dowload_data(self, username, threshold): instagram = Instagram() medias = instagram.get_medias(username, threshold) dirName = "" for media in medias: QtCore.QCoreApplication.processEvents() media = instagram.get_media_by_url(media.link) image = Image(media) dirName = image.saveImage() return dirName
def __get_account_medias_by_username(username): instagram = Instagram() medias = instagram.get_medias(username, ) media = medias[6] print(media) account = media.owner print(account) return media
instagram = Instagram() instagram.with_credentials('JJPtest123', 'jjptest', '/pathtocache') instagram.login() # If account is public you can query Instagram without auth instagram = Instagram() #f = open('lilmiquela.txt', 'w', encoding="utf-8") #account_name = input("The account name: ") #account_post_number = input("The number of post: ") #medias = instagram.get_medias(account_name, account_post_number) medias = instagram.get_medias("lilmiquela", 610) #将时间戳转换为普通时间 def time_tran(created_at): time_local = time.localtime(created_at) created_time = time.strftime("%Y-%m-%d %H:%M:%S",time_local) return created_time #media = medias[0] #account = media.owner #print(account.get_username()) cont = 0 if __name__ == '__main__': for media in medias:
instagram = Instagram() instagram.with_credentials('JJPtest123', 'jjptest', '/pathtocache') instagram.login() # If account is public you can query Instagram without auth instagram = Instagram() #f = open('lilmiquela.txt', 'w', encoding="utf-8") #account_name = input("The account name: ") #account_post_number = input("The number of post: ") #medias = instagram.get_medias(account_name, account_post_number) medias = instagram.get_medias("lil_wavi", 283) def time_tran(created_at): time_local = time.localtime(created_at) created_time = time.strftime("%Y-%m-%d %H:%M:%S", time_local) return created_time #media = medias[0] #account = media.owner #print(account.get_username()) cont = 0 if __name__ == '__main__':
instagram = Instagram() instagram.with_credentials('JJPtest123', 'jjptest', '/pathtocache') instagram.login() print('login success') # If account is public you can query Instagram without auth instagram = Instagram() #f = open('lilmiquela.txt', 'w', encoding="utf-8") #account_name = input("The account name: ") #account_post_number = input("The number of post: ") #medias = instagram.get_medias(account_name, account_post_number) medias = instagram.get_medias("bermudaisbae", 244) print('get medias success') def time_tran(created_at): time_local = time.localtime(created_at) created_time = time.strftime("%Y-%m-%d %H:%M:%S",time_local) return created_time #media = medias[0] #account = media.owner #print(account.get_username()) cont = 0 if __name__ == '__main__': print('begin scraper')
from context import Instagram # pylint: disable=no-name-in-module from time import sleep instagram = Instagram() cookie="/home/fanibi/Downloads/cookies.txt" instagram.set_cookies(cookie) #Search for account accounts = instagram.search_accounts_by_username('3.1415926535897932384626433832') print(accounts[0]) #get media account=accounts[0] account=account.username medias=instagram.get_medias(account,5) media1=medias[0] #like a picture:Does not work not logged in # instagram.like(media1.identifier) #unlike picture:Does not work not logged in # instagram.unlike(media1.identifier) #Try to get stories stories = instagram.get_stories() user_stories = stories[0] print(user_stories.owner) for story in user_stories.stories: print(story)
sleep(2) # Delay to mimic user # username = '******' # followers = [] # account = instagram.get_account(username) # sleep(1) # followers = instagram.get_followers(account.identifier, 150, 100, delayed=True) # Get 150 followers of 'kevin', 100 a time with random delay between requests # for follower in followers['accounts']: # print(follower) medias = instagram.get_medias("target_username", 25) media = medias[6] print(media) https://www.instagram.com/p/CGxmIHLge2w/ # media_links = [] # like_counter = 0 i = "https://www.instagram.com/p/CHQ5ovQHXS7/" for i in media_links:
from context import Instagram # pylint: disable=no-name-in-module # If account is public you can query Instagram without auth instagram = Instagram() medias = instagram.get_medias("kevin", 25) media = medias[6] print(media) account = media.owner print(account) # print('Username', account.username) # print('Full Name', account.full_name) # print('Profile Pic Url', account.get_profile_picture_url_hd()) # If account private you should be subscribed and after auth it will be available # username = '' # password = '' # session_folder = '' # instagram = Instagram.with_credentials(username, password, session_folder) # instagram = Instagram() # instagram.login() # instagram.get_medias('private_account', 100)
account = args.uname maxPosts = args.max csvPath = os.path.join('outputs/%s-posts.csv' % account) #proxies = { # "http": "socks5h://x2923101:[email protected]:1080", # "https": "socks5h://x2923101:[email protected]:1080", #} instagram = Instagram() #instagram.set_proxies(proxies) print("\nScraping in progress... please wait...") medias = instagram.get_medias(account, maxPosts) with open(csvPath, 'a', encoding='utf-8') as f: writer = csv.writer(f, lineterminator='\n') writer.writerow([ 'post type', 'post date', 'caption', 'likes', 'comments', 'video views', 'post url', 'post id' ]) for media in medias: with open(csvPath, 'a', encoding='utf-8') as f: writer = csv.writer(f, lineterminator='\n') writer.writerow([ media.type, media.created_time, media.caption, media.likes_count, media.comments_count, media.video_views, media.link, media.identifier
# If account is public you can query Instagram without auth instagram = Instagram() #f = open('lilmiquela.txt', 'w', encoding="utf-8") #account_name = input("The account name: ") #account_post_number = input("The number of post: ") #medias = instagram.get_medias(account_name, account_post_number) #https://www.instagram.com/lil_wavi/ account_name = "lil_wavi" account_post_number = 297 medias = instagram.get_medias(account_name, account_post_number) print('get medias success') def time_tran(created_at): time_local = time.localtime(created_at) created_time = time.strftime("%Y-%m-%d %H:%M:%S", time_local) return created_time #media = medias[0] #account = media.owner #print(account.get_username()) if __name__ == '__main__': print('begin scraper')