Python 通过premium api使用searchtweets收集归档推文

Python 通过premium api使用searchtweets收集归档推文,python,tweets,twitter-streaming-api,twitterapi-python,Python,Tweets,Twitter Streaming Api,Twitterapi Python,我曾尝试在python中使用此代码来收集旧tweet !pip install searchtweets import yaml config = dict( search_tweets_api = dict( account_type = 'premium', endpoint = 'https://api.twitter.com/1.1/tweets/search/fullarchive/Label.json', consumer_key = '******************',

我曾尝试在python中使用此代码来收集旧tweet

!pip install searchtweets
import yaml
config = dict(
search_tweets_api = dict(
 account_type = 'premium',
endpoint = 'https://api.twitter.com/1.1/tweets/search/fullarchive/Label.json',
consumer_key = '******************',
        consumer_secret = '***************************'
 )
)
with open('twitter_keys_fullarchive.yaml', 'w') as config_file:
 yaml.dump(config, config_file, default_flow_style=False) 

from searchtweets import load_credentials
premium_search_args = load_credentials("twitter_keys_fullarchive.yaml",
 yaml_key="search_tweets_api",
env_overwrite=False)
print(premium_search_args)
query = "(#COVID19 OR  # Corona_virus) (pandemic OR corona OR  infected OR vaccine)"
rule = gen_rule_payload(query, results_per_call=100, from_date="2020-02-01", to_date="2020-03-31")
from searchtweets import ResultStream
rs = ResultStream(rule_payload=rule,
  max_results=3000,
**premium_search_args)
print(rs)
import json
with open('tweetsData.jsonl', 'a', encoding='utf-8') as f:
for tweet in rs.stream():
        json.dump(tweet, f)
 f.write('\n')
print('done')
代码已运行,但我发现了一些问题,希望能帮助我避免这些问题 首先,我只想要没有转发(RT)和重复推文的推文 其次,当我将JSON文件转换为CSV文件时,我发现了一些问题,因此我可以直接将推文收集到CSV文件中吗? 第三:我希望尽可能多地收集推文,而不必再次运行代码。 最后:我尝试在查询中使用2个运算符(AND-OR),但结果不满足
我将非常感谢你对我的帮助