How to read JSON from HTML?

I know we can use Requests.jl to get the data, but I am not sure how we can parse the JSON with JSON.jl:

using Requests, JSON

r = get("")
parse( # should JSON.Parser.parse work here?
1 Like

I think you should probably try HTTP.jl

I don’t think Requests is recommended or actively maintained
quoting malmaud the biggest contributor

I think HTTP.jl is probably the future of the Julia we stack. Would be
awesome to get it merged there.

1 Like

@musm my choice for Requests.jl over HTTP.jl was based on the number of stars on GitHub (100 vs. 19), could you please confirm HTTP.jl is the future?

I can’t predict the future but here is the original quote HTTP/2 Support by sorpaas · Pull Request #133 · JuliaWeb/Requests.jl · GitHub

1 Like

The answer with HTTP.jl:

using HTTP, JSON

resp = HTTP.get("")
str = String(resp.body)
jobj = JSON.Parser.parse(s)

@juliohm, should it be JSON.parse(str) * ?

@miguelraz I don’t remember what happened, but I had to use JSON.Parser.parse(str) instead as I wrote on my answer. Maybe it has changed since then.

1 Like

JSON.parse should work, but will not autocomplete in the REPL due to a Julia REPL limitation.

1 Like

I am new to julia and came here searching for HTTP scraping…

This is our minimal sample (working as of 20201008):

import Pkg; 

import HTTP
import JSON
import JSON;
import JSON3;
import LazyJSON;

using JSON
using HTTP
using JSON;
using JSON3;
using LazyJSON;

# tags
# releases

url = ""
resp = HTTP.get(url)

str = String(resp.body)
println("str = ", str)

jobj_JSON = JSON.parse(str)
println("jobj_JSON = ", jobj_JSON)

jobj_JSON3 =
println("jobj_JSON3 = ", jobj_JSON)

jobj_LazyJSON = LazyJSON.value(str)
println("jobj_LazyJSON = ", jobj_LazyJSON)