Skip to content

Instantly share code, notes, and snippets.

@morris555
Created January 3, 2012 13:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save morris555/1554824 to your computer and use it in GitHub Desktop.
Save morris555/1554824 to your computer and use it in GitHub Desktop.
#!/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