我正在尝试从CME
https://www.cmegroup.com/market-data/cme-group-benchmark-administration/term-sofr.html中Web抓取此表
然而xml2和rvest的read_html或html函数从来不返回任何东西。有人能指导我如何将其拉入R Dataframe 吗?
我正在尝试从CME
https://www.cmegroup.com/market-data/cme-group-benchmark-administration/term-sofr.html中Web抓取此表
然而xml2和rvest的read_html或html函数从来不返回任何东西。有人能指导我如何将其拉入R Dataframe 吗?
2条答案
按热度按时间tzcvj98z1#
您可以下载网页,然后使用
read_html
读取html文件,您可以检查网页以查找表的位置(Xpath),并使用html_element
和html_table
获取数据。okxuctiv2#
如果你使用RSelenium,你仍然可以自动地从这个页面上删除表格。我认为这个方法比手动复制和粘贴HTML或表格的文本有趣得多:D
具体操作如下:
它看起来是这样的:
这种方法的一些注意事项:
1.这个页面不想被抓取,所以如果你从他们的网站上抓取了很多,我会采取措施来避免被阻止,比如在你的代码中添加延迟,添加随机的按键和鼠标移动,以及指定一个不同的用户代理。