urllib.error.URLError:
2018-11-21  本文已影响0人  hie

导入 ssl 包

import ssl

创建context,

context = ssl._create_unverified_context()

把context添加到请求,

from urllib import request

import ssl

context = ssl._create_unverified_context()

with request.urlopen('https://api.douban.com/v2/book/2129650', context=context)as f:

        data = f.read()

        print('Status:', f.status, f.reason)

        for k, vin f.getheaders():

        print('%s: %s' % (k, v))

        print('Data:', data.decode('utf-8'))

上一篇下一篇

猜你喜欢

热点阅读