1

For example, I want to scrape the data from this web-page(The Space,Amenities,Prices...and reviews https://www.airbnb.com/rooms/9985824?guests=1&s=d2dNfFMd

I want to use for this purpose rselenium package. This is my code:

url <- "https://www.airbnb.com/rooms/9985824?guests=1&s=d2dNfFMd"
library('RSelenium')
pJS <- phantom()
library('XML')
shell.exec(paste0("C:\\Users\\Daniil\\Desktop\\R-language,Python\\file.bat"))
Sys.sleep(10)

checkForServer()
startServer()
remDr <- remoteDriver(browserName="chrome", port=4444)
remDr$open(silent=T)

and then with the help of SelectorGadget I found, I think, right elements for scraping:

var <- remDr$findElements('css selector','#details hr+ .row')

My question is: how can I bring it into the text(character strings)? Or maybe exists other approach with rselenium for collecting data.

Many thanks

1 Answer 1

1

I'm not sure what is in file.bat but it appears you are primarily interested in collecting data about the amenities of the listing. I just used firefox and skipped over the phantomjs parts of your code:

url <- "https://www.airbnb.com/rooms/9985824?guests=1&s=d2dNfFMd"

library('RSelenium')

checkForServer()
startServer()
remDr <- remoteDriver(browserName="firefox", port=4444)
remDr$open(silent=T)
remDr$navigate(url)

var <- remDr$findElement('css selector','#details hr+ .row')

print(var$getElementText())
[[1]]
[1] "The Space\nAccommodates: 2\nBathrooms: 1.5\nBed type: Real Bed\nBedrooms: 1\nBeds: 1\nProperty type: Apartment\nRoom type: Private room\nHouse Rules"

From here you can parse the string or perform additional data collecting.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.