Accessing product reviews from sites
Online product reviews are a very good source of information. They can be used to judge a brand or a product. It becomes very difficult to read all the reviews, so we can write a program to get the product reviews. Let's see one of the ways to extract the customer review data from Amazon. For example, let's consider the movie Transformers – Age of Extinction and see the customer reviews:
urll<- 'http://www.amazon.com/gp/video/detail/B00L83TQR6?ie=UTF8&redirect=true&ref_=s9_nwrsa_gw_g318_i1'
First, we get the relevant URL and store it in a variable so that it can be used in the functions. Then, we need to parse the HTML content of the page and save it to the variable doc
. In order to do so, we need to import the package XML
. Now, the parsed HTML is stored in the variable doc
. Please follow the link for more details on the HTML DOM: http://www.w3schools.com/jsref/dom_obj_document.asp. The code is as follows:
library(XML) doc<- htmlParse(urll...