我是一个编程的初学者。
我在试着从推特账号上抓取推文。
当我运行我的代码时,我得到了以下错误:CRITICAL:root:twint.get:User:
下面是我正在运行的代码:
import twint
config = twint.Config()
# Search tweets tweeted by user 'BarackObama'
config.Username = "BarackObama"
# Limit search results to 20
config.Limit = 20
# Return tweets that were published after Jan 1st, 2020
config.Since = "2020-01-1 20:30:15"
# Formatting the tweets
config.Format = "Tweet Id {id}, tweeted at {time}, {date}, by {username} says: {tweet}"
# Storing tweets in a csv file
config.Store_csv = True
config.Output = "Barack Obama"
twint.run.Search(config)这个错误是否意味着Twint有问题,或者是我的代码中有错误?
谢谢!
发布于 2020-08-06 09:47:09
我也是一个初学者,试图学习python作为巴西数字历史的工具。我也遇到了同样的问题(只有在使用c.Username参数时)。我解决了运行pip3 install --upgrade -e git+https://github.com/twintproject/twint.git@origin/master#egg=twint的问题
我希望它能为你工作。
发布于 2021-01-21 17:50:37
解决方案是修改twint源代码中的user.py,并将各行替换为try和except语句。
try:
_usr.name = ur['data']['user']['legacy']['name']
except:
_usr.name = ''
try:
_usr.username = ur['data']['user']['legacy']['screen_name']
except:
_usr.username = ''
try:
_usr.bio = ur['data']['user']['legacy']['description']
except:
_usr.bio = ''
try:
_usr.location = ur['data']['user']['legacy']['location']
except:
_usr.location = ''
try:
_usr.url = ur['data']['user']['legacy']['url']
except:
_usr.url = ''https://stackoverflow.com/questions/63006722
复制相似问题