Created
January 3, 2012 13:04
-
-
Save morris555/1554824 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
#!/usr/bin/env python | |
# -*- coding:utf-8 -*- | |
import tweepy | |
import sys | |
def get_oauth(): | |
consumer_key = '' | |
consumer_secret = '' | |
access_key = '' | |
access_secret = '' | |
auth = tweepy.OAuthHandler(consumer_key, consumer_secret) | |
auth.set_access_token(access_key, access_secret) | |
return auth | |
def fav(screen_name, num, api): | |
count = 0 | |
id = 0 | |
while count < int(num): | |
if id == 0: | |
tweets = api.user_timeline(screen_name) | |
else: | |
tweets = api.user_timeline(screen_name, max_id=id) | |
for tweet in tweets: | |
id = tweet.id | |
if tweet.favorited == True: | |
pass | |
fav = api.create_favorite(id) | |
count += 1 | |
if count >= int(num): | |
return | |
de main(): | |
auth = get_oauth() | |
api = tweepy.API(auth_handler=auth) | |
if len(sys.argv) != 3: | |
sys.exit() | |
else: | |
screen_name = sys.argv[1] | |
num = sys.argv[2] | |
fav(screen_name, num, api) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment