Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/277.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Twitter REST API v1.1-按日期搜索?_Python_Twitter_Python Module - Fatal编程技术网

Python Twitter REST API v1.1-按日期搜索?

Python Twitter REST API v1.1-按日期搜索?,python,twitter,python-module,Python,Twitter,Python Module,有没有一种方法可以使用Twitter的API 1.1在某一天或上周搜索所有带有特定查询的帖子 是否有任何符合API的python模块能够做到这一点(我一直在使用twython),或者是否有任何特定的模块可以推荐用于此任务?简短回答,是 例如: #Import the required modules from twython import Twython import json import csv #Set the path for the output file path = r'C:\U

有没有一种方法可以使用Twitter的API 1.1在某一天或上周搜索所有带有特定查询的帖子


是否有任何符合API的python模块能够做到这一点(我一直在使用twython),或者是否有任何特定的模块可以推荐用于此任务?

简短回答,

例如:

#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()
然后,您只需要解析结果。你可以找到更多关于这方面的信息