def load_img_insta(user_name, pass_word): imgs = os.listdir('image2') bot = Bot() bot.login(username=user_name, password=pass_word) for img in imgs: bot.upload_photo(f'image2/{img}')
locations_tmp = locations_tmp[pos + 1:] locations.append(locations_tmp) # Appending to array last hashtag print("SETTINGS: max_likes: {}, delay: {}".format( settings['max_likes_per_day'], settings['like_delay'])) # Creating folders dir = "{}/accs/{}/logs".format(path_, args.bot_id) if not os.path.exists(dir): os.makedirs(dir) # Changing directory to instabot/accs/bot_id os.chdir("{}/accs/{}".format(path_, args.bot_id)) bot = Bot(script='like', max_likes_per_day=settings['max_likes_per_day'] + 100, like_delay=settings['like_delay']) bot.login(username=settings['login'], password=settings['password'], proxy=settings['proxy']) while True: for location in locations: print("Location: {}".format(location)) bot.api.search_location(location) finded_location = bot.api.last_json['items'][0] if finded_location: print("Found {}".format(finded_location['title'])) like_location_feed(bot, finded_location, amount=int(18)) time.sleep(settings['follow_delay']) else:
args = parser.parse_args() try: print(u'Like medias by location') except TypeError: sys.stdout = stdout bot = Bot(max_likes_per_day=800, max_unlikes_per_day=0, max_follows_per_day=200, filter_users=True, max_followers_to_follow=5000, min_followers_to_follow=200, max_following_to_follow=99999999, min_following_to_follow=600, max_followers_to_following_ratio=0.4, max_following_to_followers_ratio=100000, max_following_to_block=99999999, min_media_count_to_follow=1, follow_delay=60, like_delay=25, whitelist=False, blacklist=False, comments_file=False) bot.login(username=args.u, password=args.p, proxy=args.proxy) if args.locations: for location in args.locations: print(u"Location: {}".format(location)) bot.searchLocation(location) finded_location = bot.LastJson['items'][0]
#try: # input = raw_input #except NameError: # pass parser = argparse.ArgumentParser(add_help=True) parser.add_argument('-u', type=str, help="username") parser.add_argument('-p', type=str, help="password") parser.add_argument('-amount', type=str, help="amount") parser.add_argument('-proxy', type=str, help="proxy") parser.add_argument('locations', type=str, nargs='*', help='locations') args = parser.parse_args() try: print(u'Like medias by location') except TypeError: sys.stdout = stdout bot = Bot(stop_words=('shop', 'store', 'free', 'магазин', 'купить', 'заработок', 'аренда', 'заказать', 'доставка', 'бронирование', 'вилла')) bot.login(username=args.u, password=args.p, proxy=args.proxy) if args.locations: for location in args.locations: like_first_location_feed(bot, location, int(args.amount)) else: print("No locations")
Workflow: Block bots. That makes them unfollow you -> You have clear account. """ import argparse import os import sys sys.path.append(os.path.join(sys.path[0], "../")) from instabot import Bot # noqa: E402 parser = argparse.ArgumentParser(add_help=True) parser.add_argument("-u", type=str, help="username") parser.add_argument("-p", type=str, help="password") parser.add_argument("-proxy", type=str, help="proxy") args = parser.parse_args() stop_words = ["shop", "store", "free"] bot = Bot(stop_words=stop_words) bot.login(username=args.u, password=args.p, proxy=args.proxy) bot.logger.info( "This script will block bots. " "So they will no longer be your follower. " "Bots are those users who:\n" " * follow more than (sample value - change in file) 2000 users\n" " * have stopwords in user's info: " " %s " % str(stop_words)) bot.block_bots()
def init_bot(): LOGIN = os.getenv("LOGIN") PASSWORD = os.getenv('PASSWORD') bot = Bot() bot.login(username=LOGIN, password=PASSWORD, use_cookie=False) return bot
import threading import random import sys from mtcnn.mtcnn import MTCNN import cv2 import json import random import logging try: input = raw_input except NameError: pass COOKIES = {} bot = Bot(do_logout=True) parser = argparse.ArgumentParser(add_help=True) parser.add_argument('-u', type=str, help="username") parser.add_argument('-p', type=str, help="password") parser.add_argument('-proxy', type=str, help="proxy") args = parser.parse_args() username = str(args.u) # Check if user cookie exist bot.login(username=args.u, password=args.p, proxy=args.proxy, use_cookie=True) class Bots(object): def __init__(self):
""" instabot filtering private users example Workflow: Try to follow a private user with the bot and see how it filters that user out. """ import os import sys sys.path.append(os.path.join(sys.path[0], '../')) from instabot import Bot bot = Bot(filter_users=False, filter_private_users=False) bot.login() private_user_input = input("\n Enter a private user: ") bot.follow(bot.get_user_id_from_username(private_user_input))
bot = Bot( comments_file=config.COMMENTS_FILE, blacklist_file=config.BLACKLIST_FILE, whitelist_file=config.WHITELIST_FILE, friends_file=config.FRIENDS_FILE, followed_file='followed.txt', unfollowed_file='unfollowed.txt', skipped_file='skipped.txt', proxy=None, max_likes_per_day=1000, max_unlikes_per_day=1000, max_follows_per_day=300, max_unfollows_per_day=350, max_comments_per_day=0, max_blocks_per_day=0, max_unblocks_per_day=0, max_likes_to_like=450, max_messages_per_day=0, filter_users=True, filter_previously_followed=False, filter_business_accounts=False, filter_verified_accounts=True, max_followers_to_follow=3500, min_followers_to_follow=40, max_following_to_follow=10000, min_following_to_follow=10, max_followers_to_following_ratio=10, max_following_to_followers_ratio=2, min_media_count_to_follow=3, max_following_to_block=2000, like_delay=1, unlike_delay=10, follow_delay=130, unfollow_delay=130, comment_delay=60, block_delay=30, unblock_delay=30, message_delay=60, stop_words=(), verbosity=True, )
username = user_info['username'] name = user_info['full_name'] followers = user_info['follower_count'] following = user_info['following_count'] if "meme" in bio.lower() or "meme" in name.lower( ) or "meme" in username.lower(): if followers > 1000 and followers < 9000: if following / followers < 1.2: addToAcc.append(username) return addToAcc bot = Bot(filter_users=True, max_following_to_followers_ratio=100, max_followers_to_following_ratio=100, follow_delay=10, unfollow_delay=10, max_follows_per_day=10000, max_unfollows_per_day=10000) #this overrides the initial bot parameters bc we dont want any restrictions on it yet bot.login(username="******", password="") accounts = [] accounts.append("moisty_meme_bros") #automate this part! amt = 120 for acc in accounts:
def main(): try: ###step 1 get email data### user = "******" pwd = "*******************" imap_url = "imap.gmail.com" con = imaplib.IMAP4_SSL(imap_url) con.login(user, pwd) con.select('INBOX') res, data = con.fetch(b'1', '(RFC822)') raw = email.message_from_bytes(data[0][1]) def get_body(msg): if msg.is_multipart(): return get_body(msg.get_payload(1)) else: return msg.get_payload(None, True) def cleanhtml(raw_html): cleanr = re.compile('<.*?>') cleantext = re.sub(cleanr, '', raw_html) return cleantext text = (get_body(raw)) text = text.decode('utf-8') text = cleanhtml(text) text = text[:-2] print(text) ###step 2 delete seen email### con.store(b'1', '+FLAGS', '\\Deleted') ###step 3 load text into image generator### astr = text para = textwrap.wrap(astr, width=15) print(astr) MAX_W, MAX_H = 400, 400 im = Image.new('RGB', (MAX_W, MAX_H), (0, 0, 0, 0)) draw = ImageDraw.Draw(im) font = ImageFont.truetype("arial.ttf", 28, encoding="utf-8") current_h, pad = 50, 10 for line in para: w, h = draw.textsize(line, font=font) draw.text(((MAX_W - w) / 2, current_h), line, font=font, fill="white") current_h += h + pad source = r"C:\Users\mitth\Desktop\pics\img" + str( random.randint(0, 100000)) + ".jpg" im.save(source, "JPEG") ###step 4 image using the API### bot = Bot() bot.login(username="******", password="******") bot.upload_photo( source, caption= "New Post\n github: https://github.com/olilthanasis/anomologhtabot" ) bot.send_message(astr, ["lil_thanasis"]) # step 5 add answer to the text logs### now = datetime.now() with open(r"C:\Users\mitth\Desktop\logs.txt", "a") as myfile: myfile.write("\n" + astr + str(now)) time.sleep(5) except TypeError: time.sleep(5) pass
Workflow: Take users from input file and follow them. The file should contain one username per line! """ import argparse import os import sys sys.path.append(os.path.join(sys.path[0], '../')) from instabot import Bot parser = argparse.ArgumentParser(add_help=True) parser.add_argument('-u', type=str, help="username") parser.add_argument('-p', type=str, help="password") parser.add_argument('-proxy', type=str, help="proxy") parser.add_argument('filepath', type=str, help='filepath') args = parser.parse_args() bot = Bot(filter_users=False) users_to_follow = bot.read_list_from_file(args.filepath) bot.login(username=args.u, password=args.p, proxy=args.proxy) for ids in users_to_follow: if not users_to_follow: exit() else: print("Found %d users in file." % len(users_to_follow)) bot.follow_users(ids) users_to_follow.remove(ids)
# !/usr/bin/python3 import schedule import time import sys import os import random import yaml # ->added to make pics upload -> see job8 import glob # ->added to make pics upload -> see job8 from tqdm import tqdm import threading # ->added to make multithreadening possible -> see fn run_threaded sys.path.append(os.path.join(sys.path[0], '../../')) from instabot import Bot bot = Bot(comments_file="comments.txt") bot.login() bot.logger.info("ULTIMATE script. 24hours save") comments_file_name = "comments.txt" random_user_file = bot.read_list_from_file("username_database.txt") random_hashtag_file = bot.read_list_from_file("hashtag_database.txt") # to get pics and autopost it posted_pic_list = [] try: with open('pics.txt', 'r') as f: posted_pic_list = f.read().splitlines() except:
def get_list_nearest_locs(self, loc_name, distance=50): locs = get_nearest_locs(self, loc_name, distance=distance) for loc in locs: print(loc['location']['short_name']) def get_location_medias_from_coordinates(self, lat, lng, distance_limit=50): #проходим по всем локациям, собираем ВСЕ media #2 вариант: проходим по локациям, собираем только новые media. Стоп-флаг, если любое media уже есть в списке pass bot = Bot(comments_file=config.COMMENTS_FILE, blacklist=config.BLACKLIST_FILE, whitelist=config.WHITELIST_FILE, stop_words=config.STOP_WORDS) bot.logger = logging.getLogger('[instabot]') bot.logger.setLevel(logging.DEBUG) logging.basicConfig( format='%(asctime)s - %(levelname)s - %(threadName)s: %(message)s', filename='instabot.log', level=logging.INFO) ch = bot.logger.handlers[0] ch.setLevel(logging.DEBUG) formatter = logging.Formatter( '%(asctime)s - %(levelname)s - %(threadName)s: %(message)s') ch.setFormatter(formatter) bot.login(username=config.UNAME, password=config.UPASS)
def start(): print("Bot starting Beep Boop") current_hot = [] post_history = [] reddit = praw.Reddit(client_id='REDDIT-BOT-ID', client_secret='REDDIT-BOT-SECRET', user_agent='INSTAGRAM-BOT-NAME', username='******', password='******') subreddit = list(reddit.subreddit('blackpeopletwitter').hot(limit=12)) for submissions in subreddit[2:]: current_hot.append( (submissions.url, submissions.title, submissions.shortlink)) bot = Bot() bot.login(username="******", password="******") while True: print("trying to find new content beep boop") compare_List = [] subreddit = list(reddit.subreddit('blackpeopletwitter').hot(limit=12)) for submissions in subreddit[2:]: compare_List.append( (submissions.url, submissions.title, submissions.shortlink)) print([i for i in compare_List if i not in current_hot]) if set(compare_List) != set(current_hot): print("New post detected") temp = ([i for i in compare_List if i not in current_hot]) print(temp) current_hot = compare_List for tuples in temp: if tuples[0] not in post_history: urllib.request.urlretrieve(tuples[0], "temp.jpg") print("Picture is being posted -- beep boop") tweet_string = tweet_analysis.tweet_text("temp.jpg") try: if tweet_string != 'imgur format': bot.upload_photo("temp.jpg", caption=tuples[1] + " #reddit #blackpeopletwitter " + tweet_string) else: print("imgur format not uploadable yet") continue except RuntimeError: print("error caught!") continue post_history.append(tuples[0]) print("sucess!") now = datetime.now() current_time = now.strftime("%H:%M:%S") print("Trying again in 10 Min, current Time =", current_time) print(post_history) time.sleep(600)
import os import sys import threading import time import argparse import config from glob import glob sys.path.append(os.path.join(sys.path[0], "../../")) import schedule # noqa: E402 from instabot import Bot, utils # noqa: E402 bot = Bot( comments_file=config.COMMENTS_FILE, blacklist_file=config.BLACKLIST_FILE, whitelist_file=config.WHITELIST_FILE, friends_file=config.FRIENDS_FILE, ) parser = argparse.ArgumentParser(add_help=True) parser.add_argument("-u", type=str, help="username") parser.add_argument("-p", type=str, help="password") parser.add_argument("-proxy", type=str, help="proxy") args = parser.parse_args() bot.login(username=args.u, password=args.p, proxy=args.proxy) bot.logger.info("ULTIMATE script. Safe to run 24/7!") random_user_file = utils.file(config.USERS_FILE) random_hashtag_file = utils.file(config.HASHTAGS_FILE) photo_captions_file = utils.file(config.PHOTO_CAPTIONS_FILE) posted_pic_list = utils.file(config.POSTED_PICS_FILE).list
import os import sys from instabot import Bot bot = Bot(filter_users=True) users_to_follow = bot.read_list_from_file('followers.txt') if not users_to_follow: exit() else: print("Found %d users in file." % len(users_to_follow)) bot.login(username=str(sys.argv[1]), password=str(sys.argv[2])) bot.follow_users(users_to_follow)
The file should have one comment per line. 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) < 3: print( "USAGE: Pass a path to the file with comments and an hastag to comment" ) print("Example: %s comments_emoji.txt dog cat" % sys.argv[0]) exit() comments_file_name = sys.argv[1] hashtags = sys.argv[2:] 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, filter_users=False) bot.login(username=_inspirata, password=inspirata001) for hashtag in hashtags: bot.comment_hashtag(hashtag) bot.logout()