赞
踩
代码:
- # -*- coding: utf-8 -*-
- # @Time : 2020/4/15 16:54
- # @Author : Oneqq
- # @File : 03-https.py
- # @Software: PyCharm
-
- from urllib.request import Request, urlopen
- from fake_useragent import UserAgent
- import ssl
-
- url = "https://www.12306.cn/mormhweb"
- headers = {
- "User-Agent": UserAgent().chrome
- }
- context = ssl._create_unverified_context()
- request = Request(url, headers=headers)
- response = urlopen(request, context=context)
- info = response.read().decode()
- print(info)

结果:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。