Title Data

#lodading the package
library(xml2)
library(rvest)
library(stringr)

url <- 'https://www.amazon.in/Apple-iPhone-13-Mini-256GB/dp/B09G995NMD/ref=mp_s_a_1_1_sspa?keywords=Iphone&qid=1636724674&sr=8-1-spons&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUExT05aUk9RU09BS0gwJmVuY3J5cHRlZElkPUEwNzE5MzY1MzVHQUM5UDNBMzVYOCZlbmNyeXB0ZWRBZElkPUEwODY4ODE2MzhCRUVBN05ETkFOVyZ3aWRnZXROYW1lPXNwX3Bob25lX3NlYXJjaF9hdGYmYWN0aW9uPWNsaWNrUmVkaXJlY3QmZG9Ob3RMb2dDbGljaz10cnVl&th=1'
webpage <- read_html(url)
title_html <- html_nodes(webpage,'h1#title')
title <- html_text(title_html)
title <- str_replace_all(title,"[\r\n]","")
head(title)
## [1] "Apple iPhone 13 Mini (256GB) - Midnight"

Price Data

price_html<- html_nodes(webpage,'span#priceblock_ourprice')
price <- html_text(price_html)
price <- str_trim(price)
head(price)
## [1] "<U+20B9>79,900.00"
cat(price)
## <U+20B9>79,900.00

Rating Data

rate_html <- html_nodes(webpage,'span#acrPopover')
rate <- html_text(rate_html)
rate <- str_trim(rate)
cat(rate) 
## 4.1 out of 5 stars

Color Data

color_html <- html_nodes(webpage,'span#inline-twister-expanded-dimension-text-color_name')
color <- html_text(color_html)
color <- str_trim(color)
cat(color)
## Midnight

Size name

size_html <- html_nodes(webpage,'span#inline-twister-expanded-dimension-text-size_name')
size <- str_trim(html_text(size_html))
cat(size)
## 256GB

Feature Data

feature_html <- html_nodes(webpage,'div#feature-bullets')
feature <- str_trim(html_text(feature_html))
feature <- str_replace_all(feature,'[\n\r]','')

cat(feature)
## About this item13 cm (5.4-inch) Super Retina XDR displayCinematic mode adds shallow depth of field and shifts focus automatically in your videosAdvanced dual-camera system with 12MP Wide and Ultra Wide cameras; Photographic Styles, Smart HDR 4, Night mode, 4K Dolby Vision HDR recording12MP TrueDepth front camera with Night mode, 4K Dolby Vision HDR recordingA15 Bionic chip for lightning-fast performanceUp to 17 hours of video playbackDurable design with Ceramic ShieldIndustry-leading IP68 water resistanceiOS 15 packs new features to do more with iPhone than ever beforeSupports MagSafe accessories for easy attachment and faster wireless chargingShow More

Create Data Frame

product_data <-data.frame(Title=title,Price=price,Feature=feature,Rating=rate,Color=color,Size=size)
View(product_data)

Store data in JSON format

library(jsonlite)
json_data <- toJSON(product_data)
cat(json_data)
## [{"Title":"Apple iPhone 13 Mini (256GB) - Midnight","Price":"<U+20B9>79,900.00","Feature":"About this item13 cm (5.4-inch) Super Retina XDR displayCinematic mode adds shallow depth of field and shifts focus automatically in your videosAdvanced dual-camera system with 12MP Wide and Ultra Wide cameras; Photographic Styles, Smart HDR 4, Night mode, 4K Dolby Vision HDR recording12MP TrueDepth front camera with Night mode, 4K Dolby Vision HDR recordingA15 Bionic chip for lightning-fast performanceUp to 17 hours of video playbackDurable design with Ceramic ShieldIndustry-leading IP68 water resistanceiOS 15 packs new features to do more with iPhone than ever beforeSupports MagSafe accessories for easy attachment and faster wireless chargingShow More","Rating":"4.1 out of 5 stars","Color":"Midnight","Size":"256GB"}]

Apple Iphone 13 Mini(256GB) Data Scraping

Thank you so much for help to check Dr.