1

您好,我正在使用 tweepy 使用以下代码挖掘推文

api_key = ""
api_secret = ""
consumer_token = ""
consumer_token_secret= ""

auth = tweepy.OAuthHandler(api_key, api_secret)

auth.set_access_token(consumer_token,consumer_token_secret)


api = tweepy.API(auth)

search_words = "new normal -filter:retweets"
date_since = "2020-06-30"
tweets = tweepy.Cursor(api.search,
              q=search_words,
              lang="id",
              since=date_since).items(1000)
with io.open('file.csv', 'w', newline='', encoding="utf-16") as file:
         writer = csv.writer(file, quoting=csv.QUOTE_ALL)
         writer.writerow(["Comment"])
         for tweet in tweets:
             writer.writerow([tweet.text])

我注意到当结果是带有图像的推文时,结果只是在推文中间以“...”结尾。例如

Bhabinkamtibmas desa Cipurwasari sambangi masyarakat dan berikan Himbauan Kamtibmas serta himbauan new normal pada… https://t.co/*********

New Normal masih bingung apa aja yang harus disiapkan? #sinokkemayu bantu kamu siapkan kebutuhan saat #newnormal ni… https://t.co/*********

有什么解决方案可以让我获得整个文本吗?

4

1 回答 1

0

添加tweet_mode=extended到您的 API 调用。

于 2020-08-13T20:37:30.940 回答