install.packages(‘rvest’)
library(‘rvest’)

#Reading the HTML code from the website
url <- ‘[Website link: http://…%5D&#8217;
webpage <- read_html(url)

#Using CSS selectors to scrap the product section: Crawling Product
title_product_html <- html_nodes(webpage,’.subject a’)
#Converting the title product to text
title_product <-html_text(title_product_html)
head(title_product)

#Using CSS selectors to scrap the price section: Crawling Price
title_price_html <-html_nodes(webpage,’.dc em’)
title_price<-html_text(title_price_html)
head(title_price)

#Forming a data frame
Data <-data.frame(Product = title_product, Price = title_price)
View(Data)

Advertisements