Web在R中抓取HTML表需要花费大量时间

Web在R中抓取HTML表需要花费大量时间,r,web-scraping,rvest,xml2,R,Web Scraping,Rvest,Xml2,各位, 我正试图删除一个链接,该链接只有大约1000多条记录,但要花几个小时才能获得它们。我想知道我是否做错了什么,或者是如何将其加载到表中 urlString = "https://www.valueresearchonline.com/funds/selector-data/primary-category/1/equity/?tab=snapshot&output=html-data" urlString <- URLencode(paste0(urlSt

各位, 我正试图删除一个链接,该链接只有大约1000多条记录,但要花几个小时才能获得它们。我想知道我是否做错了什么,或者是如何将其加载到表中

urlString = "https://www.valueresearchonline.com/funds/selector-data/primary-category/1/equity/?tab=snapshot&output=html-data"
urlString <- URLencode(paste0(urlString,""))

#Reading the HTML code from the website and process the text
getHTML <- xml2::read_html(urlString, options = "HUGE")

#This one keeps running endlessly and doesn't load the table
mytable <- data.frame(getHTML %>% html_table(fill = T, trim = T))
urlString=”https://www.valueresearchonline.com/funds/selector-data/primary-category/1/equity/?tab=snapshot&output=html-数据“

URL字符串链接是一个JSON文件。您需要先通过
jsonlite
阅读它。HTML数据位于
HTML\u data
节点,您可以通过
read\u HTML
读取此节点:

json <- jsonlite::fromJSON("https://www.valueresearchonline.com/funds/selector-data/primary-category/1/equity/?tab=snapshot&output=html-data")
getHTML <- xml2::read_html(json$html_data)
mytable <- data.frame(getHTML %>% html_table(fill = T, trim = T))

json链接是一个json文件。您需要先通过
jsonlite
阅读它。HTML数据位于
HTML\u data
节点,您可以通过
read\u HTML
读取此节点:

json <- jsonlite::fromJSON("https://www.valueresearchonline.com/funds/selector-data/primary-category/1/equity/?tab=snapshot&output=html-data")
getHTML <- xml2::read_html(json$html_data)
mytable <- data.frame(getHTML %>% html_table(fill = T, trim = T))
json