2013-06-12 90 views
0

有沒有一種方法可以使用Twitter的API 1.1在特定的一天或上週對特定查詢的所有帖子進行搜索?Twitter REST API v1.1 - 按日期搜索?

任何符合API的python模塊應該能夠做到這一點(我一直在使用twython),還是有人可以推薦這個任務的特定模塊?

回答

0

簡短回答,

例如:

#Import the required modules 
from twython import Twython 
import json 
import csv 

#Set the path for the output file 
path = r'C:\Users\etc\file.txt' 

#Setting the OAuth 
Consumer_Key = 'XXX'; 
Consumer_Secret = 'XXX'; 
Access_Token = 'XXX'; 
Access_Token_Secret = 'XXX'; 

#Connection established with Twitter API v1.1 
twitter = Twython(Consumer_Key, Consumer_Secret, Access_Token, Access_Token_Secret); 

#Twitter is queried 
response = twitter.search(q='%40annoys_parrot', since = '2014-02-04', until = '2014-02-05'); 

#Results are printed 
print(json.dumps(response, sort_keys = True, indent = 2)) 

#Results are saved to txt file 
file = open(path, 'w') 
file.write((json.dumps(response, sort_keys = True, indent = 2))) 
file.close() 

然後,你只需要解析的結果。你可以找到更多關於這個here的信息。