R 刮取不带'的数据表;不存在于页面源中

R 刮取不带'的数据表;不存在于页面源中,r,post,web-scraping,web-crawler,R,Post,Web Scraping,Web Crawler,我想把这个数据表刮一下 我检查了此页面的页面源,该表在页面源中不存在 然后我在刷新网站时查看了网络信息,似乎数据表是通过向这个url发送POST请求获得的:  http://datacenter.mep.gov.cn:8099/ths-report/report!list.action 然后我尝试发送POST请求,但没有收到状态为500的任何消息 我在想,到底有没有办法用R刮掉这张桌子 谢谢。侦察得好 它正在为我发出GET请求。这似乎奏效了。它还尝试为您选择合适的目标: library(htt

我想把这个数据表刮一下

我检查了此页面的页面源,该表在页面源中不存在

然后我在刷新网站时查看了网络信息,似乎数据表是通过向这个url发送POST请求获得的: 

http://datacenter.mep.gov.cn:8099/ths-report/report!list.action
然后我尝试发送POST请求,但没有收到状态为500的任何消息

我在想,到底有没有办法用R刮掉这张桌子

谢谢。

侦察得好

它正在为我发出
GET
请求。这似乎奏效了。它还尝试为您选择合适的目标:

library(httr)
library(rvest)
library(stringi)

pg <- read_html("http://datacenter.mep.gov.cn/index!MenuAction.action?name=259206fe260c4cf7882462520e1e3ada")

html_nodes(pg, "div[onclick]") %>% 
  html_attr("onclick") %>% 
  stri_replace_first_fixed('load("', "") %>% 
  stri_replace_last_regex('",".*$', "") -> report_urls

head(report_urls)
## [1] "http://datacenter.mep.gov.cn:8099/ths-report/report!list.action?xmlname=1462849093743"
## [2] "http://datacenter.mep.gov.cn:8099/ths-report/report!list.action?xmlname=1462764947052"
## [3] "http://datacenter.mep.gov.cn:8099/ths-report/report!list.action?xmlname=1465594312346"
## [4] "http://datacenter.mep.gov.cn:8099/ths-report/report!list.action?xmlname=1462844293531"
## [5] "http://datacenter.mep.gov.cn:8099/ths-report/report!list.action?xmlname=1462844935563"
## [6] "http://datacenter.mep.gov.cn:8099/ths-report/report!list.action?xmlname=1462845592195"

rpt_pg <- read_html(report_urls[1])
html_table(rpt_pg)[[2]]
# SO won't let me paste the table 
库(httr)
图书馆(rvest)
图书馆(stringi)
pg%
html_attr(“onclick”)%%>%
stri_替换_first_fixed('负载(“,”)%>%
stri_replace_last_regex(“”、“*$”、“)->报告URL
主管(报告)
## [1] "http://datacenter.mep.gov.cn:8099/ths-报告/报告!列表.操作?xmlname=146284093743“
## [2] "http://datacenter.mep.gov.cn:8099/ths-报告/报告!列表.操作?xmlname=1462764947052“
## [3] "http://datacenter.mep.gov.cn:8099/ths-报告/报告!列表.操作?xmlname=1465594312346“
## [4] "http://datacenter.mep.gov.cn:8099/ths-报告/报告!列表.操作?xmlname=146284293531“
## [5] "http://datacenter.mep.gov.cn:8099/ths-报告/报告!列表.操作?xmlname=146284935563“
## [6] "http://datacenter.mep.gov.cn:8099/ths-报告/报告!列表.操作?xmlname=1462845592195“
rpt_pg