Last active
January 10, 2024 04:29
-
-
Save lon9/7e8d486756676ef7572a to your computer and use it in GitHub Desktop.
Function to increase follower on twitter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#キーワードで自動フォロー1000人 | |
def autoFollow(api, query): | |
requestcount=1 | |
global followCount | |
global wordCount | |
#リクエストが50回以下(検索人数1000人)で繰り返す | |
while requestcount<51: | |
print 'Do request %i' %requestcount | |
users = api.search_users(query, 20, requestcount) | |
requestcount+=1 | |
for user in users: | |
if user.following==False and user.friends_count>user.followers_count and user.follow_request_sent==False and user.id!=myId: | |
try: | |
api.create_friendship(user.id, True) | |
print 'request to %s :)' %user.id | |
followCount+=1 | |
except tweepy.error.TweepError as e: | |
print 'I could not create this friendship.:(' | |
else: | |
print 'skip to %s' %user.id | |
#フォローした人数が1000人以下なら次のワードで検索する | |
if followCount<1000 and wordCount<len(qWord) and wordCount%3!=0: | |
print qWord[wordCount] | |
query=urllib.quote(qWord[wordCount]) | |
wordCount+=1 | |
autoFollow(api, query) | |
#3回リクエストしたあとは15分の待機時間が必要 | |
elif followCount<1000 and wordCount<len(qWord) and wordCount%3==0: | |
sleep(900) #ここで15分待機 | |
query=urllib.quote(qWord[wordCount]) | |
wordCount+=1 | |
autoFollow(api, query) | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment