def followAndLikeByLocation(self): #Using Instapy to follow likers of photos session = InstaPy(username=self.username, password=self.password, headless_browser=False) with smart_run(session): """ Activity flow """ session.set_relationship_bounds(enabled=True, delimit_by_numbers=True, max_followers=4590, min_followers=45, min_following=77) session.set_user_interact(amount=5, percentage=70, randomize=True, media='Photo') # session.set_do_like(enabled=False, percentage=70) session.set_do_follow(enabled=True, percentage=70) session.set_do_comment(enabled=False, percentage=50) session.like_by_locations(['235483975/kenyatta-university/'], amount=1000)
def follow(): # Send notification to my Telegram requests.get( "https://api.telegram.org/******&text='InstaPy Follower Started @ {}'". format(datetime.now().strftime("%H:%M:%S"))) # get a session! session = get_session() # let's go! with smart_run(session): counter = 0 while counter < 5: counter += 1 try: # settings session.set_relationship_bounds(enabled=True, potency_ratio=1.21) # activity except Exception: print(traceback.format_exc()) # Send notification to my Telegram requests.get( "https://api.telegram.org/******&text='InstaPy Follower Stopped @ {}'". format(datetime.now().strftime("%H:%M:%S")))
def follow(): sendTelegram(":smile::sunglasses::smile: Follower Started") session = get_session() with smart_run(session): counter = 0 while counter < 3: counter += 1 sendTelegram("Follower part " + str(counter) + "/3 Started") try: # settings session.set_relationship_bounds(enabled=True, delimit_by_numbers=True, max_followers=30000) session.set_skip_users(skip_private=False) session.set_do_follow(enabled=True, percentage=100, times=1) # activity #session.like_by_tags(['photographerfashion'], amount=150) session.follow_user_followers(users_i_follow, amount=150, randomize=False, interact=False) session.unfollow_users(amount=120, InstapyFollowed=(True, "nonfollowers"), style="FIFO", unfollow_after=4 * 60 * 60, sleep_delay=600) except Exception: print(traceback.format_exc()) sendTelegram("Follower Exploded") sendTelegram("Follower part " + str(counter) + "/3 Finished") sendTelegram("Follower Stopped")
def unfollow_haters( session, username, unfollow_list, media_id, max_interactions ): user_id = get_user_id(username) int_id = get_interaction_id('unfollow') n = 1 with smart_run(session): for f in sample(unfollow_list, len(unfollow_list)): if n > max_interactions: return None try: session.unfollow_users(customList=(True, [f], "all")) user_followers, user_follows = session.get_follow_count(f) f_dict = { 'client_id': [user_id], 'username': [f], 'user_followers': [user_followers], 'user_follows': [user_follows], 'created_on': [datetime.now()], 'interaction_id': [int_id], 'media_id': [media_id] } follow_df = pd.DataFrame(f_dict) insert_values(follow_df, 'interactions') n += 1 take_a_nap() except Exception as e: logger.info(e) return None
def unfollow(): requests.get( "https://api.telegram.org/******/sendMessage?chat_id=*****&text" "='InstaPy Unfollower Started @ {}'".format( datetime.now().strftime("%H:%M:%S"))) # get a session! session = get_session() # let's go! with smart_run(session): try: # settings session.set_relationship_bounds(enabled=False, potency_ratio=1.21) # actions session.unfollow_users(amount=600, allFollowing=True, style="RANDOM", sleep_delay=450) except Exception: print(traceback.format_exc()) requests.get( "https://api.telegram.org/******/sendMessage?chat_id=*****&text" "='InstaPy Unfollower Stopped @ {}'".format( datetime.now().strftime("%H:%M:%S")))
def job_LikeByHashtags(): print("Started Like by hashtag") with smart_run(session): # Exclude these accounts session.set_dont_include(excludeaccounts) # like by hashtag then like their account session.set_user_interact(amount=3, randomize=True, percentage=100) session.like_by_tags(hashtagdb, amount=10, interact=True)
def interact(): # get a session! session = get_session() # let's go! with smart_run(session): try: # settings #session.set_quota_supervisor( #enabled=True, #sleep_after=["likes"], #sleepyhead=True, #stochastic_flow=True, #notify_me=True, #peak_likes=(100, 1000)) session.set_dont_include(friends) session.set_dont_like(dont_likes) session.set_ignore_if_contains(ignore_list) session.set_ignore_users(ignore_users) session.set_simulation(enabled=False) session.set_relationship_bounds(enabled=True, potency_ratio=None, delimit_by_numbers=True, max_followers=7500, max_following=900, min_followers=25, min_following=25, min_posts=2) session.set_skip_users(skip_no_profile_pic=True) session.set_user_interact(amount=5, randomize=True, percentage=80, media='Photo') session.set_do_like(enabled=True, percentage=100) session.set_do_comment(enabled=False, percentage=1) #session.set_comments([comments], media='Photo') session.set_do_follow(enabled=False, percentage=5, times=1) # actions number = random.randint(5, 9) random_targets = targets if len(targets) <= number: random_targets = targets else: random_targets = random.sample(targets, number) # Interact with the chosen targets... session.interact_user_followers(random_targets, amount=random.randint(30, 60), randomize=True) except Exception: print(traceback.format_exc())
def job_Interact(): with smart_run(session): session.set_user_interact(amount=5, randomize=True, percentage=100) session.set_do_follow(enabled=True, percentage=100) session.set_do_like(enabled=True, percentage=100) session.set_comments(commentdb) session.set_do_comment(enabled=True, percentage=80) session.interact_user_following(includeaccounts, amount=10, randomize=True)
def job_Unfollow(): print("Started unfollowing") with smart_run(session): # Exclude these accounts session.set_dont_include(excludeaccounts) # Unfollow non Followers session.unfollow_users(amount=8, nonFollowers=True, style="FIFO", unfollow_after=3 * 24 * 60 * 60, sleep_delay=0)
def unfollow(): sendTelegram("UnFollower Started") session = get_session() with smart_run(session): try: # actions session.unfollow_users(amount=400, InstapyFollowed=(True, "all"), style="FIFO", unfollow_after=8*60*60, sleep_delay=600) except Exception: print(traceback.format_exc()) sendTelegram("UnFollower Exploded") sendTelegram("UnFollower Stopped")
def follow(): # Send notification to my Telegram requests.get( "https://api.telegram.org/******&text='InstaPy Follower Started @ {}'". format(datetime.now().strftime("%H:%M:%S"))) # get a session! session = get_session() # let's go! with smart_run(session): counter = 0 while counter < 5: counter += 1 try: # settings session.set_relationship_bounds(enabled=True, potency_ratio=1.21) # activity session.follow_by_tags(['tehran', 'تهران'], amount=5) session.follow_user_followers(['donya', 'arat.gym'], amount=5, randomize=False) session.follow_by_tags([ 'کادو', 'سالن', 'فروشگاه', 'زنانه', 'فشن', 'میکاپ', 'پوست', 'زیبا' ], amount=10) session.follow_by_tags( ['لاغری', 'خرید_آنلاین', 'کافی_شاپ', 'گل'], amount=5) session.unfollow_users(amount=25, allFollowing=True, style="LIFO", unfollow_after=3 * 60 * 60, sleep_delay=450) except Exception: print(traceback.format_exc()) # Send notification to my Telegram requests.get( "https://api.telegram.org/******&text='InstaPy Follower Stopped @ {}'". format(datetime.now().strftime("%H:%M:%S")))
def IG_demo_job(): from instapy import InstaPy from instapy.util import smart_run insta_username, insta_password = InstagramHook().get_conn() # get an InstaPy session! # set headless_browser=True to run InstaPy in the background session = InstaPy(username=insta_username, password=insta_password, headless_browser=False) with smart_run(session): """ Activity flow """ # settings session.set_relationship_bounds(enabled=True, delimit_by_numbers=True, max_followers=4590, min_followers=45, min_following=77) session.set_dont_include(["friend1", "friend2", "friend3"]) session.set_dont_like(["pizza", "#store"]) # actions session.like_by_tags(["natgeo"], amount=10)
def main(): thread_count = None parser = argparse.ArgumentParser(description="Input Thread") parser.add_argument('-tc', metavar='--thread', type=int, help='thread number') parser.add_argument('-u', metavar='--username', type=str, help='Username Instagram') parser.add_argument('-p', metavar='--password', type=str, help='Password Instagram') parser.add_argument('-t', metavar='--target', type=str, help='Password Instagram') args = parser.parse_args() thread_count = args.tc username = args.u password = args.p target = args.t session = InstaPy(username=username, password=password, headless_browser=True) with smart_run(session): followers = session.grab_followers(username=target, amount='full', live_match=True) scrape = Scrape.Scrape(followers, target, thread_count) scrape.run()
def follow_users( session, username, users, media_id, max_interactions, min_followers, min_following, max_followers, follow_for_like ): user_id = get_user_id(username) int_id = get_interaction_id('follow') n = 1 for u in sample(users, len(users)): logger.info("Following {} followers".format(u)) new_session = InstaPy( username=username, password=user_data[username]['key'], headless_browser=True ) with smart_run(new_session): followers = new_session.grab_followers( username=u, amount=5 * max_interactions, live_match=False, store_locally=False ) new_session.set_relationship_bounds( enabled=True, delimit_by_numbers=True, min_followers=0, min_following=0 ) new_session.set_do_follow(enabled=True, times=1) failed_number = 0 for f in sample(followers, len(followers)): if n > max_interactions: return None if failed_number >= 10: continue try: user_followers, user_follows = session.get_follow_count(f) if not ( user_followers >= min_following and user_follows >= min_following and user_followers <= max_followers ): continue if follow_for_like: new_session.follow_likers( [f], photos_grab_amount=3, follow_likers_per_photo=25, randomize=True ) else: new_session.follow_by_list(followlist=[f]) f_dict = { 'client_id': [user_id], 'username': [f], 'user_followers': [user_followers], 'user_follows': [user_follows], 'created_on': [datetime.now()], 'interaction_id': [int_id], 'user_to_follow': [u], 'media_id': [media_id] } follow_df = pd.DataFrame(f_dict) insert_values(follow_df, 'interactions') n += 1 take_a_nap() failed_number = 0 except Exception as e: failed_number += 1 logger.info(e) continue return None
] for comment in range(5): comment = ''.join(random.sample(characters, random.randint(3, 6))) comments.append(comment) """ Like last two posts from friendlists """ if data['friends_interaction']: friends = InstaPy(username=insta_username, password=insta_password, selenium_local_session=False, disable_image_load=True, multi_logs=False) friends.set_selenium_remote_session( selenium_url='http://selenium:4444/wd/hub') with smart_run(friends): print(u'💞 Showing friends some love 💖') friends.set_relationship_bounds(enabled=False) friends.set_skip_users(skip_private=False) friends.set_do_like(True, percentage=100) friends.interact_by_users(friendlist, amount=2, randomize=False) """ Collecting followers """ bot = InstaPy(username=insta_username, password=insta_password, selenium_local_session=False, disable_image_load=True, multi_logs=False) bot.set_selenium_remote_session(selenium_url='http://selenium:4444/wd/hub') with smart_run(bot):
def job_FollowByAccount(): print("Started Follow by account") with smart_run(session): # Exclude these accounts session.set_dont_include(excludeaccounts)
'vegan', 'veganfoodshare', 'veganfood', 'whatveganseat', 'veganfoodie', 'veganism', 'govegan', 'veganism', 'vegansofig', 'veganfoodshare', 'veganfit', 'veggies' ] # prevent posts that contain some plantbased meat from being skipped ignore_list = ['vegan', 'veggie', 'plantbased'] accounts = ['accounts with similar content'] # get a session! session = InstaPy(username=insta_username, password=insta_password, headless_browser=False) with smart_run(session): # settings session.set_relationship_bounds(enabled=True, max_followers=15000) # session.set_dont_include(friends) # session.set_dont_like(dont_likes) # session.set_ignore_if_contains(ignore_list) # session.set_user_interact(amount=2, randomize=True, percentage=60) # session.set_do_follow(enabled=True, percentage=40) session.set_do_like(enabled=True, percentage=100) # activity session.like_by_tags(random.sample(like_tag_list, 3), amount=random.randint(50, 100), interact=True)
def task(): # login credentials insta_username = os.environ["INSTA_USER"] insta_password = os.environ["INSTA_PW"] # get an InstaPy session! # set headless_browser=True to run InstaPy in the background suspicious = False nogui = True use_firefox = True try: suspicious = os.environ["INSTA_SUSPICIOUS_BYPASS"] in [ 'TRUE', 'T', 't', 'true', 'True', 'Y', 'y', 'YES', 'Yes', 'yes' ] print("INSTA_SUSPICIOUS_BYPASS="******"INSTA_SUSPICIOUS_BYPASS="******"INSTA_NOGUI"] in [ 'TRUE', 'T', 't', 'true', 'True', 'Y', 'y', 'YES', 'Yes', 'yes' ] print("INSTA_NOGUI=" + str(nogui)) except: print("INSTA_NOGUI=" + str(nogui)) try: use_firefox = os.environ["INSTA_FIREFOX"] in [ 'TRUE', 'T', 't', 'true', 'True', 'Y', 'y', 'YES', 'Yes', 'yes' ] print("INSTA_FIREFOX=" + str(use_firefox)) except: print("INSTA_FIREFOX=" + str(use_firefox)) session = InstaPy(username=insta_username, password=insta_password, headless_browser=True, bypass_suspicious_attempt=suspicious, bypass_with_mobile=suspicious, use_firefox=use_firefox, disable_image_load=True, nogui=nogui) with smart_run(session): # hashtags = ["maedeprimeiraviagem", "maecoruja", "enxovaldebebe", "gravidez", "bebe", # "gestante", "amordemae", "maedeprincesa", "maedemenino", "maedemenina"] hashtags = [ "familia", "baby", "babylove", "newborn", "bebe", "meubebe", "mamae", "papai", "mae", "pai", "daddy", "dad", "mommy", "mom", "babytips", "children", "instababy", "instababies", "cutebaby", "bebelindo", "filho", "filha", "maternidade", "enxoval", "gravida", "vidademae", "maternidadereal", "maedeprimeiraviagem", "maecoruja", "enxovaldebebe", "crianca", "gestante", "pregnant", "gravidez", "amordemae", "maedeprincesa", "filhos", "maedemenino", "babyboy", "maedemenina" ] accounts = [ "paisefilhosoficial", "gravidasonline", "maedeprimeiraviagemdicas", "maeforadacaixa", "graodegente" ] comments = [u"♥ @{}", u"♥♥♥ @{}", u"♡♡♡ @{}"] locations = [ '213163910', '213088533', '213088533', '28288090', '429343414092222', '243676859' ] """ Activity flow """ # general settings # peak_server_calls = (3000, 10000) session.set_quota_supervisor(enabled=True, sleep_after=[ "likes_d", "comments_d", "follows_d", "unfollows_d", "server_calls_d" ], sleepyhead=True, stochastic_flow=True, notify_me=True, peak_likes=(45, 1000), peak_comments=(10, 200), peak_follows=(80, 1000), peak_unfollows=(80, 1000)) session.set_relationship_bounds(enabled=True, delimit_by_numbers=True, potency_ratio=1.0, max_followers=1000000, min_followers=50, min_following=50, max_following=5000, min_posts=10) session.set_dont_include(["candreoliveira", "hannacastro"]) session.set_dont_like([ "futebol", "sport", "soccer", "#cat", "[gat", "[cachorr", "[safad" "[dog", "[crazy", "]sex", "adulto" ]) # session.set_smart_hashtags(hashtags, limit=10, sort='top', log_tags=True) # session.set_mandatory_words(hashtags) # session.set_delimit_commenting( # enabled=True, min=1, comments_mandatory_words=hashtags) # session.set_skip_users(skip_private=False, # private_percentage=80, # skip_no_profile_pic=True, # skip_business=False) # session.set_dont_unfollow_active_users(enabled=True, posts=5) try: session.set_use_meaningcloud( enabled=True, license_key=os.environ["MEANINGCLOUD_LIC_KEY"], polarity="P+") print("MEANINGCLOUD_LIC_KEY=" + str(os.environ["MEANINGCLOUD_LIC_KEY"])) except: print("NO MEANINGCLOUD_LIC_KEY.") try: session.set_use_yandex(enabled=True, API_key=os.environ["YANDEX_API_KEY"], match_language=True, language_code="pt") print("YANDEX_API_KEY=" + str(os.environ["YANDEX_API_KEY"])) except: print("NO YANDEX_API_KEY.") session.set_user_interact(amount=3, percentage=50, randomize=True, media='Photo') session.follow_commenters(accounts, amount=100, daysold=365, max_pic=100, sleep_delay=600, interact=True) session.set_do_like(enabled=True, percentage=30) session.set_do_follow(enabled=True, percentage=60) session.set_do_comment(enabled=True, percentage=90) session.set_comments(comments) session.set_do_reply_to_comments(enabled=True, percentage=80) session.set_comment_replies(replies=comments) # activity session.comment_by_locations(locations, amount=10, skip_top_posts=False) # session.like_by_locations(locations, amount=100, skip_top_posts=False) session.interact_by_comments(usernames=accounts, posts_amount=10, comments_per_post=3, reply=True, interact=True, randomize=True) session.like_by_tags(hashtags, amount=100, use_smart_hashtags=False) # session.like_by_feed(amount=15, randomize=True, # unfollow=True, interact=False) session.unfollow_users(amount=1000, nonFollowers=True, style="RANDOM", unfollow_after=48 * 60 * 60, sleep_delay=180)
#getting the username and password from the .env file user_name = os.getenv('user_name') user_password = os.getenv('user_password') #A list of accounts that we need to follow their followers accounts_to_follow_followers = [ 'enockgraphics', 'beka_graphics', 'saydgraphy', 'shine_graphics', 'mr_swahili' ] session = InstaPy(username=user_name, password=user_password, want_check_browser=True) with smart_run(session, threaded=True): session.follow_user_followers(accounts_to_follow_followers, amount=20, randomize=True, interact=False) session.set_quota_supervisor(enabled=True, sleep_after=[ "likes", "comments_d", "follows", "unfollows", "server_calls_h" ], sleepyhead=True, stochastic_flow=True, notify_me=True, peak_likes_hourly=57, peak_likes_daily=585, peak_comments_hourly=21,
def job_CommentActivity(): print("Started Commenting") with smart_run(session): # Exclude these accounts session.set_dont_include(excludeaccounts)
from instapy import InstaPy from instapy.util import smart_run import os insta_username = os.environ.get('USERNAME') insta_password = os.environ.get('PASSWORD') tags = os.environ.get('TAGS').split(',') bot = InstaPy(username=insta_username, password=insta_password, headless_browser=True) with smart_run(bot): #bot.set_smart_hashtags(tags, limit=3, sort='top', log_tags=True) bot.set_relationship_bounds(enabled=True, potency_ratio=-1.21, delimit_by_numbers=True, max_followers=4590, max_following=5555, min_followers=45, min_following=77) bot.like_by_tags(tags, amount=50) bot.set_user_interact(amount=3, randomize=True, percentage=100, media='Photo') bot.like_by_tags(tags, amount=int(os.environ.get('HOURLY_LIKES'))) bot.end()
def run_app1(id_insta): #childprocess.append(multiprocessing.current_process().pid) #print("list de child", childprocess) #print("le processur pour l'utilisateur", insta_username , "est : ", os.getpid()) #print("pass", insta_username,insta_password ) # get an InstaPy session! # set headless_browser=True to run InstaPy in the background print("MULTI - Started at", datetime.datetime.now().strftime("%H:%M:%S")) #on recupere toutes les données de l'user insta_username=instausername(id_insta) insta_password=instapassword(id_insta) session = InstaPy(username=insta_username, password=insta_password, headless_browser=True) with smart_run(session): """ Activity flow """ # general settings ############################################################################### ################# BOUCLE -- BOUCLE -- BOUCLE -- BOUCLE -- BOUCLE ############## ############################################################################### while True: print("NOMBRE CONFIG==============>") #POUR N CONFIG : on parcoure n_config = nb_configuser(id_insta) print(n_config) #si aucune config (par precaution) if n_config==0: create_config(id_insta) # on recupere les infos a chaque fois pour updater le profil / en compélement du process stats session.getinfos(id_insta, insta_username) for x in range(0, n_config): #pour avoir le bon numero de config, on rajoute 1 numConfig=x+1 # ON CHERCHE LA CONFIG DE L'UTILISATEUR configuserinsta = configuser(id_insta, numConfig) #Boost a 0 de base boost = 0 # ON REGARDE S'IL A UN BOOST (null : n'existe pas, 0 : deja utilisé dans la journée , 1: a utiliser if (getBoostUser(id_insta)>=1): nbactions = random.randrange(80, 90) nbactionsFollow = random.randrange(30, 40) #on enleve donc un boost boost=getBoostUser(id_insta) else: nbactions = random.randrange(12, 16) nbactionsFollow = random.randrange(5, 8) for row in configuserinsta: id_instaconfig = row[0] n_config = row[1] actionL = row[2] actionC = row[3] actionF = row[4] actionU = row[5] minfollowing = row[6] maxfollowing = row[7] minfollowers = row[8] maxfollowers = row[9] session.set_relationship_bounds(enabled=True, delimit_by_numbers=True, max_followers=maxfollowers, min_followers=minfollowers, max_following=maxfollowing, min_following=minfollowing) #session.set_dont_include(["friend1", "friend2", "friend3"]) #session.set_dont_like(["pizza", "#store"]) #NOT INCLUDE IN SESSION # notLike= getNotLikeUser(id_insta) # session.set_dont_like(notLike) # print('Not Likes like like sont [%s]' % ', '.join(map(str, notLike))) # notInclude=getNotIncludeBio(id_insta) # session.set_dont_include(notInclude) # print('Not include sont [%s]' % ', '.join(map(str, notInclude))) likesTags = getLikesTags(id_insta, numConfig) print('les tags de like sont [%s]' % ', '.join(map(str, likesTags))) commentTags = getCommentsTags(id_insta, numConfig) print('les tags de commentaires sont [%s]' % ', '.join(map(str, commentTags))) actionL = 0 actionC = 0 actionF = 0 actionU = 0 # pour le comment : implique que le like soit activé if actionC == 1: print("COMMENT --------->") session.set_do_comment(enabled=True, percentage=25) session.set_comments(commentTags) #pour le like if actionL == 1: print("LIKE --------->") nblikes=nbactions print('le nombre de likes sera de : ',nbactions ) session.like_by_tags(likesTags,id_insta, amount=nbactions) # pour le follow if actionF == 1: print("FOLLOW --------->") nbfollows=nbactionsFollow print('le nombre de follow sera de : ', nbfollows) session.follow_by_tags(likesTags, id_insta,amount=nbfollows) # pour le unfollow if actionU == 1: print("UNFOLLOW --------->") #pour ne pas enlever les followers actifs des 15derniers posts session.set_dont_unfollow_active_users(enabled=True, posts=15) print("action Unfollow") session.unfollow_users(id_insta,amount=2, InstapyFollowed=(True, "nonfollowers"), style="FIFO", unfollow_after=60*60, sleep_delay=501) # for unfollow, verify date of first follow # session.unfollow_users(amount=random.randint(7, 10), sleep_delay=(random.randint(44, 111))) # session.set_dont_unfollow_active_users(enabled=True, posts=7) # session.follow_by_list(followlist=['portraitographers'], times=2, sleep_delay=600, interact=True) #ON UPDATE LE BOOST A 0 POUR DIRE QU'IL A ETE VALDIDE if (boost >= 1): updateBoostUser(id_insta, boost) ###################################################### #pause et insertion de la pause dans les logs timeDelay = random.randrange(1000, 1300) print("-------> sleep while:", timeDelay/60, "minutes") cur=cursor() sql_insert_query = """ INSERT INTO `logs`(`type`,`user` ) VALUES (%s, %s)""" val = ("pause", timeDelay) result = cur.execute(sql_insert_query, val) time.sleep(timeDelay) ############################################################################### ################# FIN BOUCLE -- FIN BOUCLE -- FIN BOUCLE ##################### ############################################################################### #session.end() print("ERROR -finished with error at",datetime.datetime.now().strftime("%H:%M:%S"))