从页面中抓取所有细节
Scraping all the details from the page
我正在尝试从网站上抓取一些数据,但它只存储了第一行。也许我应该 运行 一个循环或使用应用函数,但我不知道如何为网络抓取做这些。这是我的代码:
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 )
您正在使用 html_node 而不是 html_nodes
table_node<-html_nodes(nobel.table, css = '.d-con')
我正在尝试从网站上抓取一些数据,但它只存储了第一行。也许我应该 运行 一个循环或使用应用函数,但我不知道如何为网络抓取做这些。这是我的代码:
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 )
您正在使用 html_node 而不是 html_nodes
table_node<-html_nodes(nobel.table, css = '.d-con')