Pablo Barberá
January 22, 2016
An increasing amount of data is available on the web:
These data are often provided in an unstructured format.
Web scraping is the process of extracting this information automatically and transforming it into a structured dataset.
Two different scenarios:
rvest packagehttr to construct API requestsweatherData, WDI, Rfacebook… Check CRAN Task View on Web Technologies and Services for more examplesrobots.txt filesWorkflow:
rvestselectorGadgetrvestseleniumAPI = Application Programming Interface; a set of structured https requests that return data in JSON or XML format.
Types of APIs:
1. RESTful APIs: queries for static information at current moment (e.g. user profiles, posts, etc.)
2. Streaming APIs: changes in users' data in real time (e.g. new tweets, new FB posts…)
Most APIs are rate-limited:
Constructing a REST API call:
https://graph.facebook.com/?ids=barackobama,johnmccain&access_token=XXXXXResponse is often in JSON Format.
Authentication
httr package in R implements most cases (examples)Twitter:
twitteR or smappRstreamRFacebook:
Rfacebook