这是我的代码:
forbesList<-fromJSON('https://www.forbes.com/ajax/list/data?year=2018&uri=powerful-brands&type=organization')
错误详情:
Error in parse_con(txt, bigint_as_char) :
lexical error: invalid char in json text.
(!doctype html) (html lang="en")
(right here) ------^
发布于 2018-06-01 09:24:19
第一个参数fromJSON
需要是实际的JSON文本,而不是指向某些JSON文本的URL。尝试先下载JSON内容,然后fromJSON
:
library(httr)
url <- "https://www.forbes.com/ajax/list/data?year=2018&uri=powerful-brands&type=organization"
req <- GET(url)
stop_for_status(req)
json <- content(req, "text")
forbesList <- fromJSON(json)
https://stackoverflow.com/questions/-100008611
复制相似问题