def main(): # アカウント情報をロード with open('account_info.json', 'r') as f: data = json.load(f) username = data['username'] password = data['password'] # Login bot = Bot(base_path=LOG_DIR, comments_file=os.path.join(CONFIG_DIR, 'comments.txt')) bot.login(username=username, password=password) # 他人の画像をダウンロード target_user_id = "daisuke_clover" media_ids = bot.get_user_medias(user_id=target_user_id, filtration=None, is_comment=None) media_id = media_ids[0] # download photo dummy_file = os.path.join(DATA_DIR, "dummy") bot.download_photo(media_id, filename=dummy_file) dummy_file += '.jpg' # 引用する旨を伝える bot.comment_medias([media_id]) # キャプション準備 tags = ["#tokyo", "#awesomeplaces"] caption = "どこだか分かる?\n\n" caption += 'Credit: @{}\n\n'.format(target_user_id) caption += ' '.join(tags) # upload photo result = bot.upload_photo(dummy_file, caption=caption)
Workflow: 1) Get your timeline medias 2) Comment them with random comments from file. Notes: You can change file and add there your comments. """ import time import sys import os from tqdm import tqdm sys.path.append(os.path.join(sys.path[0], '../../')) from instabot import Bot if len(sys.argv) != 2: print("USAGE: Pass a path to the file with comments") print("Example: %s comments_emojie.txt" % sys.argv[0]) exit() comments_file_name = sys.argv[1] if not os.path.exists(comments_file_name): print("Can't find '%s' file." % comments_file_name) exit() bot = Bot(comments_file=comments_file_name) bot.login() bot.comment_medias(bot.get_timeline_medias()) bot.logout()
The file should have one comment per line. Workflow: 1) Get your timeline medias 2) Comment them with random comments from file. Notes: You can change file and add there your comments. """ import sys import os sys.path.append(os.path.join(sys.path[0], '../../')) from instabot import Bot if len(sys.argv) != 2: print("USAGE: Pass a path to the file with comments") print("Example: %s comments_emoji.txt" % sys.argv[0]) exit() comments_file_name = sys.argv[1] if not os.path.exists(comments_file_name): print("Can't find '%s' file." % comments_file_name) exit() bot = Bot(comments_file=comments_file_name) bot.login() bot.comment_medias(bot.get_timeline_medias()) bot.logout()