如何在python中读取url并检查HTTPS?

2024-04-19 13:37:41 发布

您现在位置:Python中文网/ 问答频道 /正文

如何在python中读取URL并检查HTTPS

import urllib2
response = urllib2.urlopen('https://www.google.com/')
html = response.read()

Tags: httpsimportcomurlreadresponsehtmlwww
1条回答
网友
1楼 · 发布于 2024-04-19 13:37:41

请尝试以下操作:

import urllib.request

response = urllib.request.urlopen('https://www.google.com/')
html = response.read()
print(html)

即使给出错误,请尝试安装以下代码并重试上述代码:

pip install urllib3

相关问题 更多 >