使用R语言jsonlite包获取福布斯网站JSON数据报错求助
R jsonlite::fromJSON() throws lexical error when fetching Forbes data
Hey everyone, I'm trying to pull 2018's most powerful brands data from Forbes using R's jsonlite package and its fromJSON() function, but I keep hitting a parsing error that I can't figure out despite trying several approaches.
Here's the code I'm running:
forbesList <- fromJSON('https://www.forbes.com/ajax/list/data?year=2018&uri=powerful-brands&type=organization')
And this is the error message I get:
Error in parse_con(txt, bigint_as_char) : lexical error: invalid char in json text. (!doctype html) (html lang="en") (right here) ------^
From the error, it looks like the response is HTML instead of JSON, but I thought the endpoint should return JSON. I've double-checked the URL, tried adjusting parameters, and even cleared my cache, but nothing seems to work.
Could someone help me troubleshoot this? I'd really appreciate any insights or solutions.
内容的提问来源于stack exchange,提问作者goutham_mi3
相关产品推荐
相关产品推荐

