我有一个存储在 csv 文件中的推文 ID 列表,我想获取每个 ID 的文本内容,然后将其与推文 ID 一起保存在 csv 文件中。这是我的代码,但它不起作用,它不返回任何结果。
def scrape_tweets(search_ids):
# Configure
for i in range(len(search_ids)):
c = twint.Config()
c.Custom["tweet"] = [search_ids[i]]
c.Store_csv = True
c.Output = os.path.join('../data_csv/{}.csv'.format(search_ids[i]))
twint.run.Search(c)
search_ids = ['1221875106206638080','1221883443467952128'] # an example for ids list
scrape_tweets(search_ids)
运行代码时出现此错误:
CRITICAL:root:twint.run:Twint:Feed:noDataExpecting value: line 1 column 1 (char 0)
sleeping for 1.0 secs
CRITICAL:root:twint.run:Twint:Feed:noDataExpecting value: line 1 column 1 (char 0)
sleeping for 8.0 secs
CRITICAL:root:twint.run:Twint:Feed:noDataExpecting value: line 1 column 1 (char 0)
sleeping for 27.0 secs
CRITICAL:root:twint.run:Twint:Feed:noDataExpecting value: line 1 column 1 (char 0)
sleeping for 64.0 secs
CRITICAL:root:twint.run:Twint:Feed:noDataExpecting value: line 1 column 1 (char 0)