r - 在 R 中抓取数据
问题描述
有没有办法在 R 中废弃数据:
本网站的一般信息/发布日期:https ://www.euronext.com/en/products/etfs/LU1437018838-XAMS/market-information
到目前为止,我已经使用了这段代码,但是生成的 XML 文件不包含我需要的信息:
library(rvest)
library(XML)
url <- paste("https://www.euronext.com/en/products/etfs/LU1437018838-XAMS/market-information",sep="")
download.file(url, destfile = "scrapedpage.html", quiet=TRUE)
content <- read_html("scrapedpage.html")
content1 <- htmlTreeParse(content, error=function(...){}, useInternalNodes = TRUE)
解决方案
你试图废弃的是一个名为 factsheet 的 AJAX 对象(我不知道 javascript,所以我不能告诉你更多)。这是获得所需内容的解决方案:使用浏览器中的网络分析(XHR 事物)获取 javascript 使用的数据的 URL。见这里。
library(rvest)
url <- read_html("https://www.euronext.com/en/factsheet-ajax?instrument_id=LU1437018838-XAMS&instrument_type=etfs")
launch_date <- url %>% html_nodes(xpath = "/html/body/div[2]/div[1]/div[3]/div[4]/strong")%>%
html_text()
推荐阅读
- sql - 基于表中出现次数的后缀字段值
- java - Invokespecial 验证错误:类型不可分配
- html - 如何在复杂的html中使用CSS选择器选择特定类型的第一个后代
- python - 如何从 Outlook(Python、win32)获取所有与日期相关的信息
- python - Django 测试:使用带参数的表单发布请求
- java - 我的日食一直说“未使用该字段的值”
- docker - Docker swarm stop 宽限期未按预期工作
- javascript - 正则表达式在 JavaScript 排序功能中无法正常工作
- html - 基金会电子邮件 --- 雷鸟 rwd
- python - GPIOZero Pi 报警系统:需要替代时间延迟