Last active
March 14, 2019 13:12
-
-
Save miyachin/f6a07f4f90aec5fb1ef726cb11dfe343 to your computer and use it in GitHub Desktop.
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
import tweepy | |
import sys | |
CONSUMER_KEY = 'xxxxxxxxxxxxxxxxxxxx' | |
CONSUMER_SECRET = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' | |
ACCESS_TOKEN = 'xxxxxxxxxxxxxxxxxxxx' | |
ACCESS_SECRET = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' | |
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET) | |
auth.set_access_token(ACCESS_TOKEN, ACCESS_SECRET) | |
api = tweepy.API(auth) | |
def execLike(keyword, threshold): | |
search_results = api.search(q=keyword, lang='ja', count=100) | |
for result in search_results: | |
if result.favorite_count > threshold and result.in_reply_to_screen_name is None: | |
twi_id = result.id | |
try: | |
api.create_favorite(twi_id) | |
except Exception as e: | |
print(e) | |
if __name__ == '__main__': | |
keyword = sys.argv[1] | |
threshold = int(sys.argv[2]) | |
execLike(keyword, threshold) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How To Run