taspinar / twitterscraper

Scrape Twitter for Tweets
MIT License
2.4k stars 580 forks source link

User tweets (python) #279

Closed ehannell closed 4 years ago

ehannell commented 4 years ago

I am trying to get tweets from a specific user, but my Python-code won't return any tweets. Is there an error in my code?

Example:

tweets = query_tweets(user='usernamehere', begindate='2019,1,1', enddate='2020,1,1', limit=1000, lang='english')

Error code:
TypeError: query_tweets() got an unexpected keyword argument 'user'
dspencer12 commented 4 years ago

Yes, there's an error in your code - the query_tweets function doesn't take a user argument. Instead, you could put the desired username in your query string: tweets = query_tweets('from:usernamehere', begindate='2019,1,1', enddate='2020,1,1', limit=1000, lang='english')

ehannell commented 4 years ago

Yes, there's an error in your code - the query_tweets function doesn't take a user argument. Instead, you could put the desired username in your query string: tweets = query_tweets('from:usernamehere', begindate='2019,1,1', enddate='2020,1,1', limit=1000, lang='english')

Perfect! Thanks a lot

edmangog commented 4 years ago

I also got the error message when I try to get tweets with user profiles. How can it be fixed?

Error code: TypeError: query_tweets() got an unexpected keyword argument 'profiles'

ehannell commented 4 years ago

I also got the error message when I try to get tweets with user profiles. How can it be fixed?

Error code: TypeError: query_tweets() got an unexpected keyword argument 'profiles'

dspencer12's solution above worked for me.

To get tweets from a certain profile do: query_tweets('from:profilename', ....)

edmangog commented 4 years ago

That works for me too:) Instead of a single user's profile, I am looking for the profile information of users from a queried list of tweets. Like the mentioned section in README.rst :

2.5 Scraping for User Profile information By adding the argument --profiles twitterscraper will in addition to the tweets, also scrape for the profile information of the users who have written these tweets. The results will be saved in the file "userprofiles_".