def index(request): api = InstagramAPI("jayabal.al", "jayabal9890@insta") if (api.login()): api.getSelfUserFeed() return JsonResponse(api.LastJson) return JsonResponse({})
def main(): import time from InstagramAPI.InstagramAPI import InstagramAPI username = input("Give username: \t") password = input("Give password: \t") hashtag = input("Give hashtag: \t") api = InstagramAPI(username, password) api.login() feed = api.getHashtagFeed(hashtag, maxid='') results = api.LastJson while True: try: next_max_id = results["next_max_id"] except: next_max_id = None for r in results["items"]: like = api.like(r["id"]) if next_max_id: feed = api.getHashtagFeed(hashtag, maxid=next_max_id) results = api.LastJson else: print("All Images liked. Bye!") quit()
def hope(bot, update): global likes_no global post_links global likes a = update.message.text username = a[1:a.find(",")] range = int(a[a.find(",") + 1:]) req = requests.get("{}{}".format(instagram_link, username)) if '200' not in str(req.status_code): bot.send_message(chat_id=update.message.chat_id, text="There is no Username with @{} on Instagram".format(username)) elif "is_private\":true" in str(req.content): bot.send_message(chat_id=update.message.chat_id, text="{} is private! @{}".format(msg['text'][1:], msg["from"]["username"])) elif not(range <= 9 and range >= 0): bot.send_message(chat_id=update.message.chat_id, text="Please use Numbers between 1 to 9") else: bot.send_message(chat_id=update.message.chat_id, text="Recevied @{} from @{}".format(username, update.message.from_user["username"])) API = InstagramAPI(USERNAME, PASSWORD) API.login() API.searchUsername(username) username_id = API.LastJson["user"]["pk"] l = API.getTotalUserFeed(username_id) ii = 0 while ii < len(l): likes_no.update({str(l[ii]["like_count"]): int(ii)}) likes.append(l[int(ii)]["like_count"]) ii = ii + 1 tt = 0 while tt < range: max_like = max(likes) max_liked_no = likes_no[str(max_like)] post_links.update({"https://www.instagram.com/p/{}".format((l[max_liked_no])["code"]): max_like}) likes.remove(max_like) tt = tt + 1 for b in post_links: like = post_links[b] bot.sendMessage(chat_id=update.message.chat_id, text="Post Link: {}\nLikes: {}".format(b, like), disable_web_page_preview=True) API.logout() likes_no.clear() post_links.clear() likes.clear() print("Logout success!")
def top_post(bot, update, args): likes_no = {} post_links = {} likes = [] # Google sheets for Storing the Chat ID of every new Telegram user who press start scope = ["https://spreadsheets.google.com/feeds", "https://www.googleapis.com/auth/drive"] credentials = ServiceAccountCredentials.from_json_keyfile_name("toppostbot.json", scope) gc = gspread.authorize(credentials) wks = gc.open("test2").worksheet("Subscribed Users") chat_id = update.message.chat_id a = args if str(chat_id) in wks.col_values(1) or int(chat_id) in admins and len(args) == 2: username = (a[0].replace(',','')).replace('@',"") range = int(a[1].replace(',','')) print("{}{}".format(instagram_link, username)) req = requests.get("{}{}".format(instagram_link, username)) if '200' not in str(req.status_code): bot.send_message(chat_id=update.message.chat_id, text="There is no Username with @{} on Instagram".format(username)) elif "is_private\":true" in str(req.content): bot.send_message(chat_id=update.message.chat_id, text="{} is private! @{}".format(username, update.message.from_user["username"])) elif not(range <= 25 and range >= 1): bot.send_message(chat_id=update.message.chat_id, text="Please use Numbers between 1 to 25") else: bot.send_message(chat_id=update.message.chat_id, text="Recevied @{} from @{}".format(username, update.message.from_user["username"])) API = InstagramAPI(USERNAME, PASSWORD) API.login() API.searchUsername(username) username_id = API.LastJson["user"]["pk"] l = API.getTotalUserFeed(username_id) ii = 0 while ii < len(l): likes_no.update({str(l[ii]["like_count"]): int(ii)}) likes.append(l[int(ii)]["like_count"]) ii = ii + 1 tt = 0 while tt < range: max_like = max(likes) max_liked_no = likes_no[str(max_like)] post_links.update({"https://www.instagram.com/p/{}".format((l[max_liked_no])["code"]): max_like}) likes.remove(max_like) tt = tt + 1 for b in post_links: like = post_links[b] bot.send_message(chat_id=update.message.chat_id, text="Post Link: {}\nLikes: {}".format(b, like), disable_web_page_preview=True) API.logout() likes_no.clear() post_links.clear() likes.clear() print("Logout success!") elif str(chat_id) in wks.col_values(1) or int(chat_id) in admins and len(args) != 2: update.message.reply_text("Your format seems to be wrong use /help to know the right format") elif str(chat_id) not in wks.col_values(1) or int(chat_id) not in str(admins): update.message.reply_text("Use this bot to get the Top Posts by an Instagram user!!\nContact @mentalgain for more...")
def date_insta_top_posts(bot, update, args): likes_no = [] post_links = [] likes = [] timestamps = [] #np.array([]) level = {} # Google sheets for Storing the Chat ID of every new Telegram user who press start scope = ["https://spreadsheets.google.com/feeds", "https://www.googleapis.com/auth/drive"] credentials = ServiceAccountCredentials.from_json_keyfile_name("toppostbot.json", scope) gc = gspread.authorize(credentials) wks = gc.open("test2").worksheet("Subscribed Users") chat_id = update.message.chat_id a = args if str(chat_id) in wks.col_values(1) or int(chat_id) in admins and len(a) == 4: username = (a[0].replace(',','')).replace('@',"") range = int(a[1].replace(',','')) date1 = (str(a[2]).replace(',','')).replace(" ","") date2 = (str(a[3]).replace(',','')).replace(" ","") A = int(time.mktime(datetime.datetime.strptime(date1, "%d/%m/%Y").timetuple())) B = int(time.mktime(datetime.datetime.strptime(date2, "%d/%m/%Y").timetuple())) # primary == smallest # secondary == biggest print("{}{}".format(instagram_link, username)) req = requests.get("{}{}".format(instagram_link, username)) # if "{} {}".format(a[2],a[3]).count("/") == 4: if date_validation(date1) == False: update.message.reply_text(text="Your First date isn't in Right Format or is not a Valid Date\nDate Format: `DD/MM/YYYY`", parse_mode='MARKDOWN') elif date_validation(date2) == False: update.message.reply_text(text="Your second date isn't in Right Format or is not a Valid Date\nDate Format: `DD/MM/YYYY`", parse_mode='MARKDOWN') elif A == B: update.message.reply_text(text="Both of your date are same.\nPlease put two different date") elif "{} {}".format(a[2],a[3]).count("/") != 4: update.message.reply_text(text="Your date format is wrong\nDate Format: `DD/MM/YYYY`", parse_mode='MARKDOWN') elif '200' not in str(req.status_code): bot.send_message(chat_id=update.message.chat_id, text="There is no Username with @{} on Instagram".format(username)) elif "is_private\":true" in str(req.content): bot.send_message(chat_id=update.message.chat_id, text="{} is private! @{}".format(a, update.message.from_user["username"])) elif not(range <= 25 and range >= 1): bot.send_message(chat_id=update.message.chat_id, text="Please use Numbers between 1 to 9") else: if A > B: primary = B secondary = A elif A < B: primary = A secondary = B bot.send_message(chat_id=update.message.chat_id, text="Recevied @{} from @{}".format(username, update.message.from_user["username"])) API = InstagramAPI(USERNAME, PASSWORD) API.login() API.searchUsername(username) username_id = API.LastJson["user"]["pk"] l = API.getTotalUserFeed(username_id) ii = 0 while ii < len(l): # np.append(timestamps, l[ii]["taken_at"]) timestamps.append(l[ii]["taken_at"]) ii = ii + 1 secondy = timestamps.index((min(timestamps, key=lambda x:abs(x-primary)))) first = timestamps.index((min(timestamps, key=lambda x:abs(x-secondary)))) tt = int(first) while tt < secondy: # likes_no.update({str(l[tt]["like_count"]): int(tt)}) likes_no.append([str(l[tt]["like_count"]), int(tt)]) # print(str(l[tt]["like_count"])) likes.append(l[int(tt)]["like_count"]) tt = tt + 1 print(likes) bot.send_message(chat_id=update.message.chat_id, text="From {} to {} there are only {} posts out of {} posts".format(date1, date2, len(likes), len(timestamps))) if range > len(likes): range = len(likes) ss = 0 while ss < range: max_like = str(max(likes)) maxed_like = likes.index(int(max_like)) max_liked_no = likes_no[int(maxed_like)][1] post_links.append(["https://www.instagram.com/p/{}".format((l[max_liked_no])["code"]), max_like]) likes.pop(maxed_like) likes_no.pop(maxed_like) ss = ss + 1 for b in post_links: like = b[1] post_linked = b[0] bot.sendMessage(chat_id=update.message.chat_id, text="Post Link: {}\nLikes: {}".format(post_linked, like), disable_web_page_preview=True) # print("Post Link: {}\nLikes: {}".format(b[0], like)) API.logout() likes_no.clear post_links.clear likes.clear timestamps.clear #np.array([]) level.clear print("Logout success!") elif str(chat_id) in wks.col_values(1) or int(chat_id) in admins and len(a) != 4: update.message.reply_text("Your format seems to be wrong use /help to know the right format") elif str(chat_id) not in wks.col_values(1) or int(chat_id) not in admins: update.message.reply_text("Use this bot to get the Top Posts by an Instagram user!!\nContact @mentalgain for more...")
def instagram_api(request): api = InstagramAPI(request.GET.get('username','yogalola22'), request.GET.get('password','yoga12345')) api.login() return api
def handle_message(message): try: #If this message isn't text, ignore it completely if(not isinstance(message.text, str)): return False #For any incoming group messages, direct the user to the DMs if message.chat.type == "group": bot.reply_to(message, "Hello! Start a conversation with me personally to get started!") #The rest of the real logic can go here else: #pull out the sending user's id, for easy access sender = message.from_user.id #make an empty interaction for this user if we don't already have one #Apparently python breaks horribly if I don't do this here if sender not in interactions: interactions[sender] = {'waitingonusername':False, 'waitingonpassword':False, 'waitingoncount':False, 'waitingonchoice1':False, 'waitingonchoice2':False, 'waitingonplatform':False, 'waiting':False} #If this user has been put on hold, tell them to sod off and ignore this message if interactions[sender]['waiting']: bot.send_message(message.chat.id, "Working, please wait before sending another message.") return False #Incoming start command if "/start" in message.text: #Get started by prompting for an instagram username interactions[sender]['waitingonusername'] = True bot.reply_to(message, "Welcome! Let's get started! This bot needs your username to perform its analysis. Reply with your Instagram username to begin! (Don't include the '@' symbol)") print("New interaction with " + str(sender)) #Okay, now that we've got an interaction going, we can start checking for user input #First, let's get the user's insta username down #We'll check to see if the username is valid immediately, and if it's not, #we'll reply with an error and return out so they can try again elif(interactions[sender]['waitingonusername']): #Put the user on hold interactions[sender]['waiting'] = True bot.send_message(message.chat.id, "Okay, let me try to find your username.") interactions[sender]['instauser'] = message.text interactions[sender]['api'] = InstagramAPI(insta_user, insta_password) #Make sure our login was successful before moving on if(interactions[sender]['api'].login()): #Before we can do anything else, we need to see if this user's account exists, and is public #If not, we'll prompt them to fix it and delete the whole interaction if(interactions[sender]['api'].searchUsername(message.text)): interactions[sender]['user'] = interactions[sender]['api'].LastJson['user'] #If this account is private, bounce out if(interactions[sender]['user']['is_private']): bot.send_message(message.chat.id, "This account is private. Sorry, but I can only analyze an account that's set to public.") return False else: bot.reply_to(message, "Couldn't find that username. Check the spelling and try again.") return False #okay, we've got a valid username to check now, so let's get the info on what the user wants interactions[sender]['waitingonusername'] = False interactions[sender]['loggedin'] = True markup = types.ReplyKeyboardMarkup() itembtn1 = types.KeyboardButton('50') itembtn2 = types.KeyboardButton('100') itembtn3 = types.KeyboardButton('200') itembtn4 = types.KeyboardButton('400') markup.row(itembtn1, itembtn2, itembtn3, itembtn4) bot.send_message(message.chat.id, "How many of your most recent followers would you like to check?\nYou can select an option below, or type any integer.", reply_markup=markup) #bot.send_message(message.chat.id, "Careful though; selecting ALL might return a Fatal Error. Use with caution.") interactions[sender]['waitingoncount'] = True #Take the user off hold interactions[sender]['waiting'] = False #If we failed to login, let the user know how to contact us. This is not an easily solved problem else: bot.reply_to(message, "Failed to log in. Contact @peteroertel on Instagram.") interactions[sender]['waitingonusername'] = True #We've got a count, now we just need to see what about their followers they want to check elif(interactions[sender]['waitingoncount']): try: if(message.text == "All"): interactions[sender]['count'] = 0 else: interactions[sender]['count'] = int(message.text) #If the user chose more than 1k, bring it down to 1k if interactions[sender]['count'] > 1000: interactions[sender]['count'] = 1000 #Put the user on hold interactions[sender]['waiting'] = True interactions[sender]['waitingoncount'] = False markup = types.ReplyKeyboardMarkup() itembtn1 = types.KeyboardButton('1.') itembtn2 = types.KeyboardButton('2.') itembtn3 = types.KeyboardButton('3.') markup.row(itembtn1, itembtn2, itembtn3) bot.send_message(message.chat.id, "Now which accounts would you like to see?\n1. Accounts that follow me and have no posts.\n2. Accounts that follow me and more than 1000 people.\n3. Accounts that follow me, 1000+ people, and who have fewer than 10 posts.", reply_markup=markup) interactions[sender]['waitingonchoice1'] = True #Take the user off hold interactions[sender]['waiting'] = False except ValueError: bot.reply_to(message, "Not a valid number, please select one of the options below.") #Okay, choice incoming. Here's where all the magic really happens elif(interactions[sender]['waitingonchoice1']): #Before we do anything, make sure the user actually made a valid choice if ("1." not in message.text) and ("2." not in message.text) and ("3." not in message.text): bot.send_message(message.chat.id, "Please select one of the buttons below.") return False else: #Put the user on hold interactions[sender]['waiting'] = True #Pretty sure the choice is valid, so save it and propmpt for the next one interactions[sender]['choice1'] = message.text markup = types.ReplyKeyboardMarkup() itembtn1 = types.KeyboardButton('1.') itembtn2 = types.KeyboardButton('2.') itembtn3 = types.KeyboardButton('3.') itembtn4 = types.KeyboardButton('4.') markup.row(itembtn1, itembtn2, itembtn3,itembtn4) bot.send_message(message.chat.id, "Of these accounts, show the ones that haven't:\n1. Liked any of my 6 most recent posts.\n2. Commented on any of my 6 most recent posts.\n3. Neither liked nor commented on my 6 most recent posts.\n4. Skip this step", reply_markup=markup) interactions[sender]['waitingonchoice1'] = False interactions[sender]['waitingonchoice2'] = True #Take the user off hold interactions[sender]['waiting'] = False elif(interactions[sender]['waitingonchoice2']): #Check for a valid choice real quick if ("1." not in message.text) and ("2." not in message.text) and ("3." not in message.text) and ("4." not in message.text): bot.send_message(message.chat.id, "Please select one of the buttons below.") return False else: interactions[sender]['choice2'] = message.text #Put the user on hold interactions[sender]['waiting'] = True #Let the user know we're working bot.send_message(message.chat.id, "Okay, give me just a minute to work.") #No matter what they choose, we'll need to call down their followers followers = interactions[sender]['api'].getTotalFollowers(interactions[sender]['user']['pk'], limit=interactions[sender]['count']) interactions[sender]['followers'] = {} #Immediately pull out all the usernames into a list #Also set a counter to break if we go over the user's selected count count = 0 for i in followers: interactions[sender]['followers'][i['pk']] = i['username'] print("Adding to list: " + i['username']) count = count + 1 if count >= interactions[sender]['count'] and interactions[sender]['count'] != 0: break #For debugging, print out the number of followers we have saved print("Total followers: " + str(len(interactions[sender]['followers']))) #Let the user know how many followers we found bot.send_message(message.chat.id, "Okay, checking " + str(len(interactions[sender]['followers'])) + " followers.") #We'll also need all of our user's recent posts #We can skip this if they chose option 4 in part 2 though if("4." in interactions[sender]['choice2']): print("Skipping gathering this user's media.") else: interactions[sender]['api'].getUserFeed(interactions[sender]['user']['pk']) media = interactions[sender]['api'].LastJson interactions[sender]['mediaids'] = [] #Just get the 10 most recent though count = 0 for i in media['items']: interactions[sender]['mediaids'].append(i['id']) count = count + 1 if count >= 6: break #Making a quick user dict, so we can store the json of each user user = {} #Start a counter so we can give updates to our user on how we're doing count = 0 total = len(interactions[sender]['followers']) checkbreak = 10 if total <= 200: checkbreak = 5 #populate the dict before we start filtering #We're doing this now so we don't have to make tons of api calls later more than once for i in interactions[sender]['followers']: #If we're at an increment of 50, let the user know if count % (total//checkbreak) == 0: print("Checked " + str(count) + "/" + str(len(interactions[sender]['followers']))) bot.send_message(message.chat.id, "Collected " + str(count) + " out of " + str(len(interactions[sender]['followers'])) + " followers.") count += 1 #We'll set the collected user state for this iteration to failed real quick, so the code #will enter this loop and continue trying to collect it until it succeeds user[i] = {'status':'fail'} while user[i]['status'] == 'fail': if(interactions[sender]['api'].searchUsername(interactions[sender]['followers'][i])): print("Found data for: " + interactions[sender]['followers'][i]) user[i] = interactions[sender]['api'].LastJson['user'] user[i]['status'] = 'ok' else: print("Couldn't find data for: " + interactions[sender]['followers'][i]) print("Relogging the api real quick...") interactions[sender]['api'].login(force=True) print("Sleeping for 10sec, trying to make sure the login worked.") sleep(10) #Let the user know we've started performing our analysis bot.send_message(message.chat.id, "Finished collecting data, performing analysis.") #FIRST OPTION STUFF #If they made the first or third choice, we need to do the few posts filter if ("1." in interactions[sender]['choice1']) or ("3." in interactions[sender]['choice1']): #Prep a list to store the keys that we'll delete later to_delete = [] for i in interactions[sender]['followers']: #Pull down the current user's media count feedcount = user[i]['media_count'] #We need to change our flag count depending on which option the user picked if("1." in interactions[sender]['choice1']): flagcount = 0 else: flagcount = 9 if feedcount > flagcount: print("Removing for too many posts: " + interactions[sender]['followers'][i]) to_delete.append(i) #Also delete from our dict of jsons, just so we don't accidentally try to iterate through a missing key later del user[i] else: print(interactions[sender]['followers'][i] + " has few enough posts. They stay on the list.") #Now that we've got the keys to delete stored, go ahead and get it done for i in to_delete: del interactions[sender]['followers'][i] #Now let's check accounts that are following more than 1000 people if("2." in interactions[sender]['choice1'] or "3." in interactions[sender]['choice1']): to_delete = [] for i in interactions[sender]['followers']: if user[i]['following_count'] < 1000: to_delete.append(i) print("Removing for to few following: " + interactions[sender]['followers'][i]) else: print("Keeping for 1000+ followers: " + interactions[sender]['followers'][i]) #Do the actual deletions for i in to_delete: del interactions[sender]['followers'][i] #SECOND OPTION STUFF #We can skip this whole damn section if they chose 4 in the second options if "4." not in interactions[sender]['choice2']: failcount = 0 for i in interactions[sender]['mediaids']: #ONLY DO THIS STEP if the user selected option 1 or 3 in the second choice #This is where we're removing people who've liked any of our recent posts if((("1." in interactions[sender]['choice2']) or ("3." in interactions[sender]['choice2'])) and (interactions[sender]['api'].getMediaLikers(i))): #Get the usernames out likers = interactions[sender]['api'].LastJson['users'] #Step through each username for k in likers: #If the username comes up in our list of followers, remove it from such list #The idea here is any usernames left in the followers list when we're done # will be the ones with no comments or likes if k['pk'] in interactions[sender]['followers']: print("Removing for likes: " + interactions[sender]['followers'][k['pk']]) del interactions[sender]['followers'][k['pk']] #ONLY DO THIS STEP if the user selected options 2 or 3 #This is where we're removing people who've commented on any of our recent posts if((("2." in interactions[sender]['choice2']) or ("3." in interactions[sender]['choice2'])) and interactions[sender]['api'].getMediaComments(i)): comments = interactions[sender]['api'].LastJson['comments'] for k in comments: if k['user']['pk'] in interactions[sender]['followers']: print("Removing for comments: " + interactions[sender]['followers'][k['user']['pk']]) del interactions[sender]['followers'][k['user']['pk']] else: print("Skipping all the media checks since the user picked 4 in part 2") #Now that we're done with additional filtering, send out our findings #For debugging, print out the number of remaining followers first off print("Found potentials: " + str(len(interactions[sender]['followers']))) if len(interactions[sender]['followers']) == 0: bot.send_message(message.chat.id, "Huh, I actually didn't find any accounts matching the criteria.") bot.send_message(message.chat.id, "If you'd like to perform another check, just reply with /start again!") else: #Set up the string we'll send directly to the user later send_string = "" count = 1 for i in interactions[sender]['followers']: #If we're already at 20 people, send it and start over if count % 20 == 0: bot.send_message(message.chat.id, send_string, parse_mode='HTML', disable_web_page_preview=True) send_string = "" send_string = send_string + str(count) + ". " + "<a href='https://instagram.com/_u/" + interactions[sender]['followers'][i] + "'>@" + interactions[sender]['followers'][i] + "</a>\n" count += 1 bot.send_message(message.chat.id, send_string, parse_mode='HTML', disable_web_page_preview=True) bot.send_message(message.chat.id, "If you'd like to perform another check, just reply with /start again!") #Take the user off hold interactions[sender]['waiting'] = False #Big-ass catch-all, just in case we're sent garbage when we weren't expecting it else: bot.send_message(message.chat.id, "Hello! Reply with /start to get started!") #Dump message to console, for extra debugging points print(message.text) except: traceback.print_exc() interactions[sender]['waiting'] = False print("FATAL ERROR: BAD BAD BAD") print("<<Check to make sure the API isn't maxed out whydontya>>") bot.send_message(message.chat.id, "FATAL ERROR: API maxed out.") bot.send_message(message.chat.id, "Try again with fewer followers, or with a different analysis option.")
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Use text editor to edit the script and type in valid Instagram username/password from InstagramAPI.InstagramAPI import InstagramAPI import time from datetime import datetime media_id = '1477006830906870775_19343908' # stop conditions, the script will end when first of them will be true until_date = '2017-03-31' count = 100 API = InstagramAPI("jayabal.al", "jayabal9890@insta") API.login() API.getUsernameInfo() has_more_comments = True max_id = '' comments = [] while has_more_comments: _ = API.getMediaComments(media_id, max_id=max_id) # comments' page come from older to newer, lets preserve desc order in full list for c in reversed(API.LastJson['comments']): comments.append(c) has_more_comments = API.LastJson.get('has_more_comments', False) # evaluate stop conditions if count and len(comments) >= count: comments = comments[:count]
def main(): # choose post dictionary post_dictionary = dictionaries.choose_dictionary() # acquire all new content from dictionary, fill queue for posting xx.acquire_all(post_dictionary['dict']) # login to session throigh instagram api print('input username') IGUSER = input() # # print('input password') # # PASSWD = input() PASSWD = getpass.getpass() # call to api igapi = InstagramAPI(IGUSER, PASSWD) # start the mongo client, access the posts database client = pymongo.MongoClient() db = client.post_database posts = db.posts # print('test printing post') # pprint.pprint(posts.find_one()) # q = fill_queue(q) with open("post_map", "r") as f: map_content = f.readlines() # print(map_content) for x in map_content: # print('x : ', x) # y = x.clone() y = copy.copy(x) y = y.replace("\n", "") q.put(ObjectId(y)) post_queue.put(posts.find_one(ObjectId(y))) # print(q.get()) i = 0 igapi.login() # login while not post_queue.empty(): # print(q.get()) # print(post_queue.get()) entry_filter = str(q.get()) # remove the dequeued() entry from the list map_content.remove(entry_filter + "\n") # XXX # open the post_map file, and write back the remaining entries with open("post_map", "w") as f: # XXX for x in map_content: # XXX f.write(x) # XXX p = post_queue.get() print('posting next, #' + str(i)) tag_lst_builder = [] i = 0 while i < len(post_dictionary['tags']): tag_lst_builder.append('#' + post_dictionary['tags'][i]) i += 1 tags = ' '.join(tag_lst_builder) try: igapi.uploadPhoto( p['image_path'], " ∴ " + "Source : @" + p['username'] + " ∴ " + tags) except AttributeError: print('ig uploading error, probably a video') pass time.sleep(time_between_posts) i += 1 igapi.logout()
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Use text editor to edit the script and type in valid Instagram username/password from InstagramAPI.InstagramAPI import InstagramAPI api = InstagramAPI("jayabal.al", "jayabal9890@insta") if (api.login()): api.getSelfUserFeed() # get self user feed print(api.LastJson) # print last response JSON print("Login succes!") else: print("Can't login!")