python编程从入门到实践. 下载数据出错

<python编程从入门到实践》第十六章 下载数据 16.2.1 运行报错
from __future__ import (absolute_import, division, print_function,
                        unicode_literals)
try:
    # Python 2.x 版本
    from urllib2 import urlopen
except ImportError:
    # Python 3.x 版本
    from urllib.request import urlopen  # 1
import json
import requests
import pygal
import math
from itertools import groupby

json_url = 'https://raw.githubusercontent.com/muxuezi/btc/master/btc_close_2017.json'
response = urlopen(json_url)  # 2
# 读取数据
req = response.read()
# 将数据写入文件
with open('btc_close_2017_urllib.json', 'wb') as f:  # 3
    f.write(req)
# 加载json格式
file_urllib = json.loads(req.decode('utf8'))  # 4
print(file_urllib)

json_url = 'https://raw.githubusercontent.com/muxuezi/btc/master/btc_close_2017.json'
req = requests.get(json_url)  # 1
# 将数据写入文件
with open('btc_close_2017_request.json', 'w') as f:
    f.write(req.text)  # 2
file_requests = req.json()  # 3


print(file_urllib == file_requests)

Traceback (most recent call last):
  File "C:\Users\Administrator.DESKTOP-5CJ81BQ\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 1348, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
  File "C:\Users\Administrator.DESKTOP-5CJ81BQ\AppData\Local\Programs\Python\Python310\lib\http\client.py", line 1282, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "C:\Users\Administrator.DESKTOP-5CJ81BQ\AppData\Local\Programs\Python\Python310\lib\http\client.py", line 1328, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "C:\Users\Administrator.DESKTOP-5CJ81BQ\AppData\Local\Programs\Python\Python310\lib\http\client.py", line 1277, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "C:\Users\Administrator.DESKTOP-5CJ81BQ\AppData\Local\Programs\Python\Python310\lib\http\client.py", line 1037, in _send_output
    self.send(msg)
  File "C:\Users\Administrator.DESKTOP-5CJ81BQ\AppData\Local\Programs\Python\Python310\lib\http\client.py", line 975, in send
    self.connect()
  File "C:\Users\Administrator.DESKTOP-5CJ81BQ\AppData\Local\Programs\Python\Python310\lib\http\client.py", line 1447, in connect
    super().connect()
  File "C:\Users\Administrator.DESKTOP-5CJ81BQ\AppData\Local\Programs\Python\Python310\lib\http\client.py", line 941, in connect
    self.sock = self._create_connection(
  File "C:\Users\Administrator.DESKTOP-5CJ81BQ\AppData\Local\Programs\Python\Python310\lib\socket.py", line 824, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "C:\Users\Administrator.DESKTOP-5CJ81BQ\AppData\Local\Programs\Python\Python310\lib\socket.py", line 955, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11004] getaddrinfo failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Administrator.DESKTOP-5CJ81BQ\Desktop\书-python编程从入门到实践随书下载\《Python编程》源代码文件\chapter_16\btc-master (16.2)\btc_close_2017.py", line 23, in <module>
    response = urlopen(json_url)  # 2
  File "C:\Users\Administrator.DESKTOP-5CJ81BQ\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
  File "C:\Users\Administrator.DESKTOP-5CJ81BQ\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 519, in open
    response = self._open(req, data)
  File "C:\Users\Administrator.DESKTOP-5CJ81BQ\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 536, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
  File "C:\Users\Administrator.DESKTOP-5CJ81BQ\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 496, in _call_chain
    result = func(*args)
  File "C:\Users\Administrator.DESKTOP-5CJ81BQ\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 1391, in https_open
    return self.do_open(http.client.HTTPSConnection, req,
  File "C:\Users\Administrator.DESKTOP-5CJ81BQ\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 1351, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 11004] getaddrinfo failed>

查过方法,说是DNS问题,修改以后也没有用,然后挂了代理,又出现了ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:997。不知道怎么解决了
我想要达到的结果

你这个代码老了
应该是人家网站改版过了, 这个要爬取数据的网站地址或参数已经变更了,

https://raw.githubusercontent.com/muxuezi/btc/master/btc_close_2017.json 地址现在已经失效打不开了

你这个代码已经过期
要爬取什么数据, 需要从现在的网站重新在有这个数据的页面中重新找到改版过后的数据地址和参数,
如果数据json字典的格式也变了,还需要重新分析json字典写对应的代码从json字典中提取数据

你这url地址有问题

访问的这个url失效了,你可以用浏览器试一下。
应该是网站更新换了url
需要去找一下这个新的url,然后根据参数重新修改现在的代码

https://raw.githubusercontent.com/muxuezi/btc/master/btc_close_2017.json 这个url过期了,换个可以访问的试试

网址有问题,复制网址去浏览器看看能不能打开