Skip to content

Instantly share code, notes, and snippets.

@kdmgs110
Created July 9, 2017 04:19
Show Gist options
  • Save kdmgs110/39e434da7ce1d833b46c67559de5828d to your computer and use it in GitHub Desktop.
Save kdmgs110/39e434da7ce1d833b46c67559de5828d to your computer and use it in GitHub Desktop.
import oauth
api = oauth.api
q = "http://review-of-my-life.blogspot.jp/*" #自分のブログのURL *は正規表現?で、これから下のものはすべてということ
count = 10 #取得するツイートの数
search_results = api.search(q=q, count=count)
for result in search_results:
username = result.user._json['screen_name']
user_id = result.id #ツイートのstatusオブジェクトから、ツイートidを取得
print(user_id)
user = result.user.name #ツイートのstatusオブジェクトから、userオブジェクトを取り出し、名前を取得する
print(user)
tweet = result.text
print(tweet)
time = result.created_at
print(time)
try: #すでにふぁぼってる人をふぁぼるとエラーがでるので、try文にしてある
api.create_favorite(user_id) #ファヴォる
print(user)
print("をライクしました")
except:
print("もうすでにふぁぼしています")
print("##################")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment