Vis*_*Raj 5 python request python-requests
我有一个在 Ubuntu 操作系统中运行的服务器,我正在使用 Python 来学习。
我启动了一个安装的应用程序,当我在浏览器中打开该应用程序时,该页面不安全,如下所示 -

我使用 python 从该页面获取一些数据 -
from urllib3.exceptions import InsecureRequestWarning
import requests
requests.urllib3.disable_warnings(category=InsecureRequestWarning)
req = requests.get(url='https://127.0.0.1:7001', verify=False)
Run Code Online (Sandbox Code Playgroud)
这显示了一个错误 -
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='127.0.0.1', port=7001): Max retries exceeded with url: / (Caused by
NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fc2ae5f94f0>: Failed to establish a new connection: [Errno 111] Connection refused'))
Run Code Online (Sandbox Code Playgroud)
当我打印变量req来检查状态时,但 python 显示变量未定义
怎么解决这个问题,谢谢
\n\nHTTPSConnectionPool(主机='127.0.0.1',端口=443)
\n
443 是 HTTPS 的默认端口。
\n您可能(我们看不到您如何定义url,但这是我最好的猜测)尝试https://127.0.0.1/...,而不是https://127.0.0.1:7001/...\xe2\x80\x93 修复代码中的问题。