Book Image

R Web Scraping Quick Start Guide

By : Olgun Aydin
Book Image

R Web Scraping Quick Start Guide

By: Olgun Aydin

Overview of this book

Web scraping is a technique to extract data from websites. It simulates the behavior of a website user to turn the website itself into a web service to retrieve or introduce new data. This book gives you all you need to get started with scraping web pages using R programming. You will learn about the rules of RegEx and Xpath, key components for scraping website data. We will show you web scraping techniques, methodologies, and frameworks. With this book's guidance, you will become comfortable with the tools to write and test RegEx and XPath rules. We will focus on examples of dynamic websites for scraping data and how to implement the techniques learned. You will learn how to collect URLs and then create XPath rules for your first web scraping script using rvest library. From the data you collect, you will be able to calculate the statistics and create R plots to visualize them. Finally, you will discover how to use Selenium drivers with R for more sophisticated scraping. You will create AWS instances and use R to connect a PostgreSQL database hosted on AWS. By the end of the book, you will be sufficiently confident to create end-to-end web scraping systems using R.
Table of Contents (7 chapters)

Regular expression language (Regex)

Regular expressions are extremely useful when they are used to extract information from any text by searching for a specific sequence of ASCII or Unicode characters. The web is frequently used in search operations. One of the most impressive features of Regex is that it can be used in almost all programming languages. Basically, a regular expression is a formula that helps explain a text. RegEx's name comes from the mathematical theory underlying the idea. It is usually shortened to regex or regexp.

You can use regular expressions with a text bean that you can usually access using your programming language. If it is known how a Regex engine works, it will be easier to generate regexes. It will be easy to understand why you cannot do what you expect with a regular expression and write more complex expressions.

There are basically only two...