Reputation: 41
I'm trying to scrape some data from website but it only stores the first row. Maybe I should run a loop or use apply function but I don't know how to do that for web scraping. Here is my code:
library(rvest)
nobel.table <- read_html("https://niir.org/directory/directory/agriculture-agro-based-companies/z,,dc,0,32/index.html")
table_node<-html_node(nobel.table, css = '.d-con')
agro<-html_text(table_node)
agro<-gsub('Mobile:', '\r\n', agro)
agro<-gsub('Tel:', '\r\n', agro)
elem<-unlist(strsplit(agro, '\r\n'))
m <- matrix( elem , ncol = 8 , byrow = TRUE )
Upvotes: 0
Views: 53
Reputation: 71
You are using html_node instead of html_nodes
table_node<-html_nodes(nobel.table, css = '.d-con')
Upvotes: 1