twitteR r package: How to get as many tweets as po

2019-05-21 18:17发布

I'm a novice R and twitteR package user but I wasn't able to find a strong recommendation on how to accomplish the following.

I'd like to mine a small number of twitter accounts to identify their output for keyword usage. (i.e. I don't know what the keywords are yet)

Assumptions:

  1. I have a small number of tweeter accounts (<6) I want to mine with a max of 7000 tweets if you aggregate the various account statuses
  2. Those accounts are not generating new tweets at a fast rate (a few a day)
  3. The accounts all have less than 3200 tweets according to the profile data returned by lookupUsers()

When I use the twitteR function userTimeline("accountname", n=3200) I get between 40 and 600 observations returned i.e no where near the 3200. I know there are API limits but if it was an issue of limits I would expect to get the same number of observations back or get the notice that I need to wait 15 mins

How do I get all the text I need while still playing nice ?

标签: r twitter
2条回答
不美不萌又怎样
2楼-- · 2019-05-21 18:43

By using a combination of cran and github packages it was possible to get all the tweets for a user

The packages used were streamR available in cran and https://github.com/SMAPPNYU/smappR/ to help with the analysis and getting the tweets.

The basic steps are

  1. Authenticate to twitter using oauth and your twitter keys, tokens and secrets
  2. use smappR function getTimeline() which saves the tweets to a json file you specify
  3. Use parseTweets(jsonfile) to read the json contents into a dataframe
查看更多
Evening l夕情丶
3楼-- · 2019-05-21 18:55

This can be accomplished with rtweet package, which is still supported. First you need to be approved as a developer and create an app. (As a note, twitter has now changed their policies, and approval can take a while. It took me almost a week.)

After that, just use get_timeline() to get all of the tweets from a timeline, up to 3200.

djt <- get_timeline("adamgreatkind", n = 3200)
查看更多
登录 后发表回答