Webscraping Vignette
This coding demo (45 minutes) shows three examples of webscraping. The frist two are very easy examples where a table exists on the page and two or three function calls are enough to download the data and covert it into a tibble. The third is much more complex, and shows you how to use the code inspector to find the elements corresponding to your data, how to extract those elements using rvest, and how to use a function to automate the process for the entire website.
You can download the code for this vignette for the course github page by clicking here: WebscrapingVignette.R
Somewhat more prepared file: WebscrapingVignetteOld.R (this isn’t the live file that I was typing)
You can watch the video on youtube youtube by clicking here.
This video had some mishaps (had to stop several times because of stuff falling in my house, also sunlight started blocking my computer screen so the process became clunky). A past version of this vignette took me 45 minutes and was a bit smoother for the IMDB website, so if you are watching and finding my video annoying check the past one by clicking here.
Helpful resources for this subject include chapter 26 of your textbook and the ‘rvest’ package, and the website for selector gadget
Other helpful resources:
- The
CSSSelector Tutorial - The
politepackage