我必须从站点获取json的内容并使用python解析它们。我写了这段代码:
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)
我有这个错误:" json对象必须是str,而不是' bytes'"。我不知道如何继续我的剧本,任何想法?
答案 0 :(得分:0)
您已经导入了请求(此模块可以处理它)
response = requests.get("http://opendata.arpa.emr.it/services/arkiweb/datasets/")
a_dict = json.loads(response.content)
答案 1 :(得分:0)
试试这段代码:
import urllib, json
url = "http://opendata.arpa.emr.it/services/arkiweb/datasets/"
response = urllib.urlopen(url)
data = json.loads(response.read())
print data