0

我正在使用 twitter 客户端 twarc,它接受 aquery和 a start_timeend_time并在该时间范围内获取推文。问题是,它从最近一次检索许多推文,并且在遇到条件(例如,页数或max_results)时停止,因此结果不平衡。我将如何拥有它,以便它在一个时间范围内每天获得 X 条推文?

search_results = client.search_recent(query=query, start_time=start_time, end_time=end_time, max_results=max_results)

for idx, page in enumerate(search_results):
    for tweet in ensure_flattened(page):
        # get different tweet attributes here
    if idx > max_pages:
        break

我可以运行一段时间而不是提前中断,但我使用的是沙盒模式,我担心我会达到限制。我能想到的唯一方法是有一个从 开始的循环,start_time在每个循环之后添加一天,获得 X 条推文,当它到达 时end_time,它会停止/中断。但我猜这似乎不是很有效。

4

0 回答 0