'''
ssl证书,https
'''
from urllib.request import urlopen
from urllib.request import Request
from urllib.parse import urlencode
import ssl
url = 'https://www.12306.cn/index/'
headers={
'User-Agent':'Mozilla/5.0(Windows;U;WindowsNT6.1;en-us)AppleWebKit/534.50(KHTML,likeGecko)Version/5.1Safari/534.50'
}
request = Request(url, headers=headers)
#忽略证书
context=ssl._create_unverified_context()
response = urlopen(request,context=context)
info = response.read().decode()
print(info)
(4)爬虫 ssl证书,https
最新推荐文章于 2024-07-30 19:45:21 发布