Collecting data with RSelenium

Let's start collecting data from Instagram by using the RSelenium library. First of all, we have to load the RSelenium library using the following command: 

#loading libraries library(RSelenium)

Now we load Selenium drivers and start Selenium. It may take time, so please wait till loading finishes: 

#loading drivers and starting selenium rD <- rsDriver() remDr <- rD[["client"]]

During loading drivers, you will see the following output on your RStudio console: 

Loading Selenium Server

Let's navigate an Instagram post that has a packtpub hashtag:

#navigate post which has packtpub hashtagremDr$navigate("https://www.instagram.com/p/BiFW2XFD8CM/?hl=en&tagged=packtpub") ...

Get R Web Scraping Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.