[英]Tweepy : AttributeError : Status object has no attribute _json
[英]tweepy Status object (tweet) has no attribute .text
使用 Tweepy Python 庫我連接了一個 Twitter 帳戶的憑據和 stream 實時推文與感興趣的術語相關的文件然后,我想將它們保存到 atxt 文件中。
然后我想讀取我們收集到的所有數據到 pandas DataFrame
請問我該怎么做。
這是我的代碼: cursor = tweepy.Cursor(api.user_timeline, id='CarrefourFrance',tweet_mode='extended').items(33)
with open('t.txt', 'w') as f:
for tweet in cursor:
try:
f.write('{}\n'.format(tweet.text.encode("utf-8")))
except UnicodeEncodeError as e:
print(e)
這是錯誤: AttributeError: 'Status' object has no attribute 'text'
也許您應該嘗試將tweet.text
更改為tweet.full_text
或者是這樣的:
results = api.search(q=query, lang=language, count=tweetCount, tweet_mode='extended')
for tweet in results:
print(tweet.full_text)
供參考: https://github.com/tweepy/tweepy/issues/878
並查看擴展模式的文檔:
使用擴展模式時,由 tweepy.API 方法返回的 Status 對象的 text 屬性被替換為 full_text 屬性,該屬性包含 Tweet 的整個未截斷文本。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.