def upload(filepath, uname, pword): """ Uploads a given image to the supplied user account with the supplied password Image must be a jpg and square """ print 'Uploading ' + filepath + '\n' insta = InstagramAPI.InstagramAPI(uname, pword) insta.uploadPhoto(filepath)
def __init__(self): rospy.Service('photo_upload', UploadImage, self.upload_image) user = rospy.get_param('~user') password = rospy.get_param('~password') path = rospy.get_param('~instagram_path') self.instagram = InstagramAPI.Instagram(user, password, IGDataPath=path) try: self.instagram.login() except Exception as e: e.message exit()
def main(): username = '' password = '' InstagramAPI = ig.InstagramAPI(username, password) instructions = open("img_and_caption.txt", 'r') for instruction in instructions: InstagramAPI.login() # login instruction = instruction.rstrip('\n') stuff = instruction.split(" | ") file = stuff[1] caption = stuff[0] buzzwords = ["wholesome"] words = caption.split(" ") for word in words: if word.lower() in buzzwords: words[words.index(word)] = "#" + word caption = " ".join(words) type = file.split(".") print(file) try: if "mp4" in type: print('Attempting to post mp4...') video_path = 'pics/' + file print(video_path) thumbnail = get_thumbnail('pics/' + file, type[0]) InstagramAPI.uploadVideo(video_path, thumbnail, caption) print("Made post!") elif "jpg" in type: print('Attempting to post jpg...') photo_path = 'pics/' + file print(photo_path) InstagramAPI.uploadPhoto(photo_path, caption) print("Made post!") except: print("Something went wrong with posting the image") InstagramAPI.logout() time.sleep(random.randint(30, 100))
def __init__(self, bot_config=None): """ Constructor :param bot_config: Bot configuration object. """ # Auth to Instagram config = bot_config.instagram self._instagram = InstagramAPI.Instagram( username=config['username'], password=config['password'], IGDataPath=config['data_path']) self._page = None self._followers = list() self._current_follower = 0 self._config = config # History self._histories = { 'follow': list(), 'unfollow': list(), 'post': list(), 'comment': list(), 'like': list() } self._counts = { 'follow': 0, 'unfollow': 0, 'post': 0, 'comment': 0, 'like': 0 } # Limits self._limits = dict() self._limits['follow'] = bot_config.friends['max_new_followers'] self._limits['unfollow'] = bot_config.friends['max_new_unfollow'] self._limits['post'] = bot_config.post['max_posts'] self._limits['comment'] = bot_config.post['max_comments'] self._limits['like'] = bot_config.post['max_likes']
import time logging.basicConfig(filename='instascript.log', level=logging.DEBUG) USERNAME = '' PASSWORD = '' with open("settings.json") as f: settings = json.load(f) USERNAME = settings['username'] PASSWORD = settings['password'] logging.info("the username is [{0}]. the password is [{1}].".format(USERNAME, PASSWORD)) three_days_ago = int(time.time()) - 259200 #60*60*24*3 client = InstagramAPI.InstagramAPI(USERNAME, PASSWORD) try: if client.login(): followers = client.getTotalSelfFollowers() followers_with_no_posts = [] for follower in followers: if follower['is_private']: continue posts = client.getTotalUserFeed(follower['pk'], three_days_ago) if len(posts) == 0: followers_with_no_posts.append(follower) continue
import InstagramAPI # /////// CONFIG /////// username = '' password = '' debug = False photo = '' # path to the photo caption = '' # caption # ////////////////////// i = InstagramAPI.Instagram(username, password, debug) try: i.login() except Exception as e: e.message exit() try: i.uploadPhoto(photo, caption) except Exception as e: print e.message
import InstagramAPI from time import sleep from Info import InstagramPW as pw from Info import InstagramUsername as usr num = 12 Insta = InstagramAPI.Instagram(usr, pw) Insta.openMyPost(1) while (True): Insta.Refresh() sleep(4) Insta.loadComments() unrepliedComments = Insta.getCommentsWithoutReply() if bool(unrepliedComments) == False: print("No unreplied comments") continue i = unrepliedComments[0] print("i:", i, "& comment:", Insta.getTextCommentOfIndex(i)) Insta.clickReplyButton(i) try: guess = int(Insta.getTextCommentOfIndex(i)) except: Insta.textToPost( "I'm sorry, this comment wasn't reconized as a whole number") sleep(30) continue if guess > num: Insta.textToPost( "Guess lower (in a new comment, don't reply to this one)")
def make_client(username, password): client = InstagramAPI.InstagramAPI(username, password) with hidden_output(): client.login() return client
# текущее время current_time = time.time() # 2 суток в секундах two_days_unix_time = 172800 # время с которого начинаем парсить посты, если в конфиге не задан min_timestamp feed_capture_time = current_time - two_days_unix_time # количество аккаунтов acc_count = len(auth_data.items()) + 1 # +1 для последнего акка # логинимся с одного акка для сбора фида и необходимых метрик с целевого аккаунта login, pw = auth_data.get(1).split(",") current_session = InstagramAPI.InstagramAPI(login, pw) current_session.login() # получить id целевого аккаунта по его имени user_id = tools.get_userid_by_username(slaveholder_account_name) # если в конфиге не задан min_timestamp, то получаем фид страницы за два дня if tools.get_setting("Bot_settings", "min_timestamp") == "0": print("2 days filter") feed_as_list = current_session.getTotalUserFeed(user_id, int(feed_capture_time)) # иначе фильтруем фид по min_timestamp из конфига else: print("last post filter") feed_as_list = current_session.getTotalUserFeed(user_id, int(tools.get_setting("Bot_settings", "min_timestamp"))) # количество отфильтрованых постов
import InstagramAPI # // NOTE: THIS IS A CLI TOOL # /// DEBUG MODE /// debug = False r = InstagramAPI.InstagramRegistration(debug) print "###########################" print "# #" print "# Instagram Register Tool #" print "# #" print "###########################" def do_get_username(): new_username = raw_input("\n\nUsername: "******"Username " + username + " not available, try with another one\n" username, is_available = do_get_username() print "Username " + username + " is available\n\n" password = raw_input("\nPassword: ").strip()
# try: full_name = eval(('"' + full_name + '"').replace('\\\\u', '\\\\u')) print(full_name) except UnicodeEncodeError: full_name = source[first_index:last_index] bot.editMessageText((from_id, msg_id), user_info % (full_name, username, 'instagram.com/' + username), 'Markdown', reply_markup=inline_keyboard_maker( [[('دانلود عکس پروفایل', username + ' profile ' + str(msg_id))], [('دانلود استوریها', username + ' story ' + str(msg_id))], [('دانلود لایوها', username + ' live ' + str(msg_id))], [('قرعهکشی بین اعضای پیج', username + ' lottery ' + str(msg_id))] ] ) ) api = InstagramAPI.InstagramAPI(def_username, def_password) api.login() print('Instagram logged in') bot = telepot.Bot(TOKEN) MessageLoop(bot, {'chat': message_handler, 'callback_query': callback_query}).run_as_thread() print('Program is running...') while True: time.sleep(30)
def __init__(self, username, password): global api api = InstagramAPI.InstagramAPI(username, password) api.login()
except: print('Timezone module is being crappy again...') while True: conn = sqlite3.connect('IG_auto_upload.sqlite') cur = conn.cursor() cur.execute( 'CREATE TABLE IF NOT EXISTS instagram(post_time CHAR(50) PRIMARY KEY NOT NULL, photo CHAR(300) NOT NULL, caption CHAR(500) NOT NULL)' ) print('Looking at the queue database...') est_time = datetime.now(timezone) print('EST now is {}/{}/{}...'.format(est_time.day, est_time.month, est_time.hour)) api = IG.InstagramAPI(Login_details['id'], Login_details['pw']) cur.execute( 'SELECT post_time, photo, caption FROM instagram ORDER BY post_time ASC' ) print('Loading the queue...') data = cur.fetchall() if len(data) == 0: print('There is no post to be scheduled...') time.sleep(7200) continue post_list = list() for entry in data:
import InstagramAPI from time import sleep from Info import InstagramPW as pw from Info import InstagramUsername as usr Insta = InstagramAPI.Instagram(usr, pw) #logs in Insta.openMyPost(1) #opens the second (index of 1) post on my profile Insta.loadComments() #loads all the comments in on that post comment = Insta.getCommentEqualTo( 11 ) #gets me the first comment which has the number n as an index and string in an array #comment = [index of comment, text of comment] if comment == None: #If no comments were found, print no match found print("No match was found") else: # If a comment was found... print(comment[1]) #print the comment which was found Insta.clickReplyButton( comment[0] + 2) #click the reply button of the index the comment was found Insta.textToPost( "You sent me the number " + comment[1] + " and that's very cool." ) #post this comment to to the person you'd like to reply to sleep(20) #Don't close browser until 20s
# В период за месяц с 1 по 30 (31) ведём сбор вовлеченности. # 1. Количество постов. # 2. Количество лайков. # 3. Количество комментариев. # 4. Количество подписчиков. # если файл с фидами есть, удаляем его перед началом работы if os.path.exists("feed.json"): os.remove("feed.json") # узнаем user_id целевого аккаунта user_id = tools.get_userid_by_username('serpuhov_ru') # логинимся current_session = InstagramAPI.InstagramAPI("andrewa374", "1q2w3e4r5t") current_session.login() # получаем количество подписчиков целевого аккаунта followers_count = str(len(current_session.getTotalFollowers(user_id))) # собираем фид за месяц feed_as_list = current_session.getTotalUserFeed(user_id, tools.seconds_from_start_month()) # дампим полученный фид в json-файл with open("feed.json", "w") as f: json.dump(feed_as_list, f, indent=4) # открываем дамп для подсчета метрик with open("feed.json", "r") as feed: