def main(): api = setup_api(consumer_key, consumer_secret, access_key, access_secret) file_path = "tweets.txt" tweet_data = read_list(file_path) tweet_text = pick_random_element(tweet_data) # get target target_accounts = api.friends() done = False while not done: target_account = pick_random_element(target_accounts) is_followed = is_followed_by(api, target_screen_name=target_account.screen_name) if is_good_account(target_account) and not is_followed: reply(api, tweet_text, target_account) done = True
def main(): ids = [] listfollowers =[] i =0 save_file = open("list_followers.txt","rw+") api = setup_api(consumer_key, consumer_secret, access_key, access_secret) for page in tweepy.Cursor(api.followers,screen_name="NameofAccount").pages(): i +=1 #use cursor for bypass 20 view limit from twitter while len(page) >0: listfollowers = page.pop() if is_good_account(listfollowers): print>> save_file,listfollowers.screen_name print listfollowers.screen_name ids.extend(page) time.sleep(60)
def main(): api = setup_api(consumer_key, consumer_secret, access_key, access_secret) file_path = 'famous_accounts.txt' accounts = read_list(file_path) for account in accounts: print '### From follower of ', account try: followers = api.followers(account) for follower in followers: if is_good_account(follower): print follower.screen_name try: friend = api.create_friendship(follower.screen_name) if friend.screen_name == follower.screen_name: print 'Follow ' + follower.screen_name + ' success' else: print 'Follow ' + follower.screen_name + ' failed' except tweepy.TweepError, e: print e except Exception, e: print e