I'm trying to scrape "1,335,000" from the screenshot below (the number is at the bottom of the screenshot). I wrote the following code in R.
t2<-read_html("https://fortune.com/company/amazon-com/fortune500/")
employee_number <- t2 %>%
rvest::html_nodes('body') %>%
xml2::xml_find_all("//*[contains(@class, 'info__value--2AHH7')]") %>%
rvest::html_text()
However, when I call "employee_number", it gives me "character(0)". Can anyone help me figure out why?
Data is loaded dynamically from a
script
tag. No need for expense of a browser. You could either extract the entire JavaScript object within thescript
, pass tojsonlite
to handle as JSON, then extract what you want, or, if just after the employee count, regex that out from the response text.