On Sun, Jan 5, 2025 at 5:54 PM Joshua Ulrich <josh.m.ulr...@gmail.com> wrote: > > On Sun, Jan 5, 2025 at 5:41 PM Sparks, John <jspa...@uic.edu> wrote: > > > > Hi Josh, > > > > Thanks for helping me with my second topic of the day. > > > > I am scraping from the fmpcloud website and trying to get data from their > > survivorship free data (so they say). > > > > The result is supposed to be in json format, but I can't figure out how to > > get any of R's json interpreters to parse the result. > > > > The programming in R to get the initial data is > > > > html <- > > read_html("https://fmpcloud.io/api/v4/historical-price-full/ABI/2005-01-04?apikey=1af241eb87c43cfa7e124419cb180d7e") > > > > Any (additional) guidance would be appreciated. > > > That's a REST API endpoint. It responds with JSON, not HTML. So you just need > > <untested code failure omitted> > Correction, that should be either x <- jsonlite::parse_json(url("https://fmpcloud.io/api/v4/historical-price-full/ABI/2005-01-04?apikey=1af241eb87c43cfa7e124419cb180d7e")) # or x <- jsonlite::fromJSON("https://fmpcloud.io/api/v4/historical-price-full/ABI/2005-01-04?apikey=1af241eb87c43cfa7e124419cb180d7e")
> > --John Sparks > > ________________________________ > > From: Joshua Ulrich <josh.m.ulr...@gmail.com> > > Sent: Sunday, January 5, 2025 2:55 PM > > To: Sparks, John <jspa...@uic.edu> > > Cc: r-help@r-project.org <r-help@r-project.org> > > Subject: Re: [R] Help Parsing String? From HTML > > > > CAUTION: External Sender > > > > On Sun, Jan 5, 2025 at 2:03 PM Sparks, John via R-help > > <r-help@r-project.org> wrote: > > > > > > Hi, > > > > > > I am scraping some data from the internet and I got what I want but in a > > > big long string (sort of) and can't figure out a way to parse it. > > > > > What site are you scraping? There may be an easier way to get the data on > > it. > > > > > What I have gotten to is > > > > > > > mystring > > > {xml_nodeset (1)} > > > [1] <p>{\n "symbol": "ABI",\n "open": 21.04,\n "high": 21.05,\n > > > "low": 20.06,\n "close": 20.2,\n "volume": 938700,\n "from": > > > "2005-01-04"\n}</p> > > > > > > But I can't find a way to isolate the individual elements such as symbol, > > > open, etc. > > > > > > I'll bet there is someone out there with a lot more experience at html > > > parsing than me who can see a way to solve this in minutes. > > > > > > Any guidance would be appreciated. > > > > > > --John Sparks > > > > > > [[alternative HTML version deleted]] > > > > > > ______________________________________________ > > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > > https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-help&data=05%7C02%7Cjspark4%40uic.edu%7C7bd4229e6e74413d678c08dd2dcb5cff%7Ce202cd477a564baa99e3e3b71a7c77dd%7C0%7C0%7C638717073670167325%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=vpJ%2Bva%2BI%2Fnm1bBXakuB34TSW%2BV832R4sOgyYCAq6iIA%3D&reserved=0 > > > PLEASE do read the posting guide > > > https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.r-project.org%2Fposting-guide.html&data=05%7C02%7Cjspark4%40uic.edu%7C7bd4229e6e74413d678c08dd2dcb5cff%7Ce202cd477a564baa99e3e3b71a7c77dd%7C0%7C0%7C638717073670183537%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=HDxFV4GG6w%2Fut71t3IHHEz%2FTw3kiKYZeuxZvvbGCG7A%3D&reserved=0 > > > and provide commented, minimal, self-contained, reproducible code. > > > > > > > > -- > > Joshua Ulrich | about.me/joshuaulrich > > > > This email originated from outside the University of Illinois System. Use > > caution when replying, clicking links, or opening attachments. DO NOT reply > > to any requests asking you to reply from a personal account or SMS. -- Joshua Ulrich | about.me/joshuaulrich FOSS Trading | www.fosstrading.com ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide https://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.