MartinKBeck / TwitterScraper

Repository containing all files relevant to my basic and advanced tweet scraping articles.
196 stars 117 forks source link

How would you combine the time span of dates and the specific user in the query? #4

Closed kevinhuang99 closed 3 years ago

kevinhuang99 commented 3 years ago

Is there any way to get tweets from a specific time span from a specific user? I've trying different things out on jupyter notebook and gotten just blank dataframes returned. Thank you.

MartinBeckUT commented 3 years ago

Sorry for the late reply, always in and out from my GitHub.

Depends on the type of method you use for scraping.

Using terminal commands most likely something similar to this.

I'm assuming you're using snscrape.

snscrape --jsonl --max-results 500 --since 2020-06-01 twitter-search 'from:john its the elephant until:2020-07-31' > text-query-tweets.json

I'd avoid using twitter-user with dates I know it gets sort of weird. Do note, this will not pull all tweets that are on a users "Twitter timeline" because the from operator will only pull tweets that a person themself has authored. If you want exactly what's available on a users timeline you'll have to use Tweepy instead.