Reputation: 55
I am currently using the rtweet package to conduct API calls on twitter.
It would seem that the easiest way to pull the tweets i want, is by using get_timelines(). At the moment I have set n = 100 just to try an pull som tweets.
get_timelines(c("politician1", "politician2", "politician3"), n = 100)
However, my question is: is it possible to use a command along with the get_timelines in order to retrieve tweets from a specified period in time? I want to retrieve tweets between Oktober 20th and November 20th 2020.
Or would it be better just to filter the dataframe by the dates I want?
Best
Upvotes: 0
Views: 1014
Reputation: 55
Okay, so i looked at https://github.com/ropensci/rtweet/issues/312 for answers to this particular question. Because the API doesn't allow for "since" and "until" parameters, you can use the id from tweets that are at the same dates as one would want.
So to set a "since" date of 2019-02-01, simply select a tweet from 31 Jan 2019 e.g. "1090887065456148481" To set an "until" date of 2019-02-04, similarly choose a tweet from 5 Feb 2019 e.g. "1092889267674599424"
result <- get_timeline("screenname", n = 100, parse = TRUE, since_id = "1090887065456148481", max_id = "1092889267674599424", type = "recent") %>%
dplyr::filter(created_at > "2019-01-31" & created_at <="2019-02-04")
It should be noted, that I am not to claim credit for this answer, I am simply reporting the answer from the link above.
Upvotes: 2