Reputation: 31
I'm a beginner with coding.
I'm trying to scrape tweets from a Twitter account.
I'm getting the following error when I run my code: CRITICAL:root:twint.get:User:
Here is the code that I'm running:
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)
Does this error mean it's a problem with Twint, or is there a mistake in my code?
Thank you!
Upvotes: 3
Views: 5977
Reputation: 148
The solution is in modifying user.py in the twint source, and replace lines with a try and except statement.
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 = ''
Upvotes: 1
Reputation: 91
I'm a beginner as well, trying to learn python as a tool for Digital History in Brazil.
I was getting the same problem (only when using c.Username parameter).
I solved running pip3 install --upgrade -e git+https://github.com/twintproject/twint.git@origin/master#egg=twint
I hope it works for you.
Upvotes: 7