0

I'm trying to find an easy way to scrape Tweeter data using a hashtag. For example, I would like to be able to scrape all tweets that contain #testhash.

I've seen a couple of posts, especially one (http://www.datablog.sytpp.net/2014/04/scraping-twitter-with-r-a-how-to/), but it seems the tweetR package is corrupt (doesn't install on my computer and makes R crash). Any idea would be great, but I am particularly familiar with R, so that would be even better.

Thomas
  • 43,637
  • 12
  • 109
  • 140

1 Answers1

2

In April 2015, the code in the blog post you mentioned no longer works for me (with twitteR v1.1.8).

And I don't know why you don't succeed with installing the twitteR package. Try to install the dependencies yourself, one-by-one. For each:

methods, bit64, rjson, DBI , httr , twitteR

run

install.packages("methods")
#...

Maybe that helps finding out about the problem.

Then I just tried this (quick and dirty solution. do not share your plaintext credentials with anyone):

library(twitteR)

#, please see https://apps.twitter.com/
consumerKey = "PH...."   # from your app name
consumerSecret = "zr...."
accessToken = "5199999-22...."
accessSecret = "94..."
options(httr_oauth_cache=TRUE) # skip question appearing on console
setup_twitter_oauth(consumer_key = consumerKey, consumer_secret = consumerSecret,
                    access_token = accessToken, access_secret = accessSecret)

# tweets about beer
searchTwitter("#beer", n=100)
# tweets about Berlin
searchTwitter("#berlin", n=100)
# tweets about nerds
searchTwitter("#nerds", n=100)
# tweets about R
#Rtweets(n=42)
# ...
##########################################################################
## lets test out what our session limits look like now after these requests
##########################################################################
rate.limit <- getCurRateLimitInfo()
# print out all metrics that have been changed
rate.limit[rate.limit$limit != rate.limit$remaining,]
knb
  • 9,138
  • 4
  • 58
  • 85