def get_users_accounts(): media_id = get_media_id() for username, vals in user_data.items(): ck = vals['consumer_key'] cs = vals['consumer_secret'] at = vals['access_token'] ats = vals['access_token_secret'] auth = tweepy.OAuthHandler(ck, cs) auth.set_access_token(at, ats) api = tweepy.API(auth, wait_on_rate_limit=True) client_id = get_user_id(username) followers, follows = get_account_data(api) client_dict = { 'client_id': [client_id], 'media_id': [media_id], 'followers': [len(followers)], 'follows': [len(follows)], 'follower_users': [json.dumps(followers)], 'created_on': [datetime.now()] } client_df = pd.DataFrame(client_dict) insert_values(client_df, 'clients_accounts') return None
def turn_unfollow_on(max_interactions, media_id, unfollow_num='dino'): for username, vals in user_data.items(): is_test = vals['is_test'] if is_test: continue logger.info("Unfollowing for {}".format(username)) key = vals['key'] client_id = get_user_id(username) session = InstaPy(username=username, password=key, headless_browser=True) if unfollow_num == 'dino': unfollow_list = get_dino_follows(client_id, media_id, 'follow') else: unfollow_list = session.grab_followers(username=username, amount=unfollow_num, live_match=False, store_locally=False) if len(unfollow_list) == 0: continue unfollow_haters(session, username, unfollow_list, media_id, max_interactions) logger.info("Finished unfollowing") return None
def turn_follow_on(max_interactions, media_id): for username, vals in user_data.items(): logger.info("Following for {}".format(username)) ck = vals['consumer_key'] cs = vals['consumer_secret'] at = vals['access_token'] ats = vals['access_token_secret'] users_to_copy = vals['users_to_copy'] auth = tweepy.OAuthHandler(ck, cs) auth.set_access_token(at, ats) api = tweepy.API(auth, wait_on_rate_limit=True) follow_users(api, username, users_to_copy, media_id, max_interactions) logger.info("Finished following") return None
def turn_follow_on(test_user, max_interactions, media_id, follow_for_like): for username, vals in user_data.items(): if username != test_user: continue logger.info("Following for {}".format(username)) key = vals['key'] users_to_copy = vals['users_to_copy'] min_followers = vals['min_followers'] max_followers = vals['max_followers'] min_following = vals['min_following'] session = InstaPy( username=username, password=key, headless_browser=True ) follow_users( session, username, users_to_copy, media_id, max_interactions, min_followers, min_following, max_followers, follow_for_like ) logger.info("Finished following") return None