Created
July 9, 2017 04:19
-
-
Save kdmgs110/39e434da7ce1d833b46c67559de5828d 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 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