How to arrange web scraped data in a table using R?
Original Code
library(netstat)
library(RSelenium)
library(tidyverse)
obj-rsDriver(browser=chrome,chromever=101.0.4951.15,verbose=F,port=free_port())
remDr-obj$client
remDr$navigate('https://www.imdb.com/search/title/?year=2022title_type=feature')
Title-remDr$findElements(using='css','.lister-item-header a')
lapply(Title,function(x) { x$getElementText()%% unlist() })
o/p:
[[1]] 1 Doctor Strange in the Multiverse of Madness
[[2]] 1 Senior Year
My attempts to arrange data in tabular form-
1.movies=data.frame(Title,stringsAsFactors=FALSE)
view(movies)
**Error in as.data.frame.default(x[[i]], optional = TRUE) : cannot coerce class ‘structure(webElement, package = RSelenium)’ to a data.frame**
2.movies=data.frame(x,stringsAsFactors=FALSE)
view(movies)
**Error in data.frame(X, stringsAsFactors = FALSE) : object 'X' not found**
3.Part of original code tweaked-
lapply(Title,function(x) { **t-list(x$getElementText()%% unlist())** })
l=data.frame(movie=t,stringsAsFactors = FALSE)
view(l)
**Error in as.data.frame.default(x[[i]], optional = TRUE) : cannot coerce class ‘function’ to a data.frame**
Desired Output-
Topic structured-data web-scraping visualization r
Category Data Science