Skip to main content

16  Scraping: rvest (todo)

Until this chapter gives a 200 OK, check out our earlier scraping tutorial (part II)

Note

Proposed chapter scope: Web scraping with rvest. Covers reading HTML, selecting elements with CSS selectors, and extracting structured data from a single page. Then the code is wrapped in a function and applied to many pages with map and list_rbind: this is where functions and map are first introduced, and where lists first appear (as what map returns). A callout shows a for loop (“you’ll see this in other people’s code”) next to its map equivalent.

webR runs in the browser, so CORS blocks scraping most live sites. Host the practice pages on the book’s own site (same origin), so readers still make real HTTP requests to real HTML.