-1

I have to get json's contents from a site and parsing them with python. I wrote this code :

import requests
import codecs
import urllib
import urllib3
from urllib.request import urlopen
import json

url = "http://opendata.arpa.emr.it/services/arkiweb/datasets/"

response = urllib.request.urlopen(url)
data = json.loads(response.read())
print(data)

I have this error : "the json object must be str, not 'bytes'". I don't know how to continue my script, any ideas?

nickmeck
  • 17
  • 4

2 Answers2

0

you have already imported requests (this module can deal with it)

response = requests.get("http://opendata.arpa.emr.it/services/arkiweb/datasets/")
a_dict = json.loads(response.content)
Jonathan
  • 486
  • 3
  • 12
0

Try this code :

import urllib, json
url = "http://opendata.arpa.emr.it/services/arkiweb/datasets/"
response = urllib.urlopen(url)
data = json.loads(response.read())
print data
Babacar Gningue
  • 1,304
  • 1
  • 9
  • 10