【问题标题】:How to extract tabular data from a website using R如何使用 R 从网站中提取表格数据
【发布时间】:2019-01-28 10:45:03
【问题描述】:

我正在尝试从网页中提取数据 https://www.geojit.com/other-market/world-indices 和许多其他类似的。

我需要获取网站的表格数据(INDEX,NAME,COUNTRY,CLOSE,PREV.CLOSE,NET CHANGE,CHANGE (%),LAST UPDATED DATE & TIME)。如果您可以为此共享 R 代码,那就太好了,否则欢迎任何帮助。

library(rvest)
library(dplyr)   
google <- html("https://www.geojit.com/other-market/world-indices")    
google %>%    
html_nodes()

【问题讨论】:

  • 看看我的答案是否适合你。
  • 是的,谢谢:)

标签: r web-scraping data-extraction


【解决方案1】:
library(rvest)
my_tbl <- read_html("https://www.geojit.com/other-market/world-indices") %>%    
  html_nodes(xpath = "//*[@id=\"aboutContent\"]/div[2]/table") %>%
  html_table(header = TRUE) %>%
  `[[`(1)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-06-13
    • 2020-06-14
    • 2023-04-06
    • 1970-01-01
    • 2021-10-29
    • 2019-04-17
    • 1970-01-01
    • 2021-11-29
    相关资源
    最近更新 更多