当前位置:网站首页>Secure credit

Secure credit

2022-04-23 17:58:00 Feng Ye 520

import urllib
import ssl
#https = http+ssl( Secure socket layer )

# Manually increase credit
# Create a SSLContext object
context = ssl._create_unverified_context()

url = "https://www.12306.cn/mormhweb/"
ua_headers = {"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36"}

# HTTP Request
req = urllib.request.Request(url,
                             headers=ua_headers)
# HTTP Response
response = urllib.request.urlopen(req, 
                       context=context)

with open("12306.html", "wb") as f:
    f.write(response.read())
#CertificateError:
 

版权声明
本文为[Feng Ye 520]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230546152115.html