我正在尝试从此url中读取表:
https://www.nseindia.com/live_market/dynaContent/live_analysis/most_active_underlyings.htm
library(rvest)
library(magrittr)
url = "https://www.nseindia.com/live_market/dynaContent/live_analysis/most_active_underlyings.htm"
tbl = read_html(url) %>% html_node("table") %>% html_table()
错误消息:
Error in matrix(NA_character_, nrow = n, ncol = maxp) :
invalid 'ncol' value (too large or NA)
In addition: Warning messages:
1: In max(p) : no non-missing arguments to max; returning -Inf
2: In matrix(NA_character_, nrow = n, ncol = maxp) :
NAs introduced by coercion to integer range
答案 0 :(得分:1)
似乎可以通过this URL
上的GET请求获得基础数据要将其放入R ...使用此
library(jsonlite)
tmp <- fromJSON("https://www.nseindia.com/live_market/dynaContent/live_analysis/underlyings/ActiveUnderlyingsValue.json")
df <- tmp$data
> head(df)
FO_SYMBOL VOLUME1 VOLUME2 TOTAL_VOLUME VALUE1 VALUE2 TOTAL_VALUE UNDERLYINGVALUE
1 BANKNIFTY 1,36,046 83,23,989 84,60,035 8,521.68 5,23,514.39 5,32,036.07 31,160.35
2 NIFTY 1,01,176 41,10,138 42,11,314 9,050.23 3,69,056.93 3,78,107.16 11,856.80
3 SBIN 49,403 75,206 1,24,609 4,722.48 7,455.53 12,178.01 313.20
4 RELIANCE 15,093 30,744 45,837 1,183.71 2,459.68 3,643.39 1,564.90
5 TCS 20,578 40,737 61,315 1,044.29 2,139.57 3,183.86 2,016.25
6 ICICIBANK 21,264 19,857 41,121 1,548.93 1,462.62 3,011.55 529.75
OP OPENINTEREST
1 1,824.84 7,75,725
2 1,349.93 15,54,357
3 143.40 69,024
4 27.77 1,29,759
5 26.17 1,00,669
6 23.59 99,142