Py学习  »  问与答

[Python]requests访问地址报错,但是使用后浏览器是可以正常登录的

casillas88 • 3 年前 • 1182 次点击  

在网上面搜索了很久也没有找到解决方案 报错: C:\Software\Python\Python38\python.exe C:/Users/*/PycharmProjects/Demo/BSF/WorkOrderReport.py Traceback (most recent call last): File "C:\Users**\AppData\Roaming\Python\Python38\site-packages\urllib3\connection.py", line 158, in _new_conn conn = connection.create_connection( File "C:\Users**\AppData\Roaming\Python\Python38\site-packages\urllib3\util\connection.py", line 80, in create_connection raise err File "C:\Users*\AppData\Roaming\Python\Python38\site-packages\urllib3\util\connection.py", line 70, in create_connection sock.connect(sa) ConnectionRefusedError: [WinError 10061] 由于目标计算机积极拒绝,无法连接。

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users**\AppData\Roaming\Python\Python38\site-packages\urllib3\connectionpool.py", line 597, in urlopen httplib_response = self._make_request(conn, method, url, File "C:\Users*\AppData\Roaming\Python\Python38\site-packages\urllib3\connectionpool.py", line 354, in _make_request conn.request(method, url, httplib_request_kw) File "C:\Software\Python\Python38\lib\http\client.py", line 1230, in request self._send_request(method, url, body, headers, encode_chunked) File "C:\Software\Python\Python38\lib\http\client.py", line 1276, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "C:\Software\Python\Python38\lib\http\client.py", line 1225, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "C:\Software\Python\Python38\lib\http\client.py", line 1004, in _send_output self.send(msg) File "C:\Software\Python\Python38\lib\http\client.py", line 944, in send self.connect() File "C:\Users**\AppData\Roaming\Python\Python38\site-packages\urllib3\connection.py", line 181, in connect conn = self._new_conn() File "C:\Users*\AppData\Roaming\Python\Python38\site-packages\urllib3\connection.py", line 167, in _new_conn raise NewConnectionError( urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x0000014B372DC160>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users**\AppData\Roaming\Python\Python38\site-packages\requests\adapters.py", line 439, in send resp = conn.urlopen( File "C:\Users*\AppData\Roaming\Python\Python38\site-packages\urllib3\connectionpool.py", line 637, in urlopen retries = retries.increment(method, url, error=e, _pool=self, File "C:\Users****\AppData\Roaming\Python\Python38\site-packages\urllib3\util\retry.py", line 399, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='211.138.236.215', port=9081): Max retries exceeded with url: /IOMPROJ/logon.jsp (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x0000014B372DC160>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:/Users/*/PycharmProjects/Demo/BSF/WorkOrderReport.py", line 294, in <module> login1() File "C:/Users//PycharmProjects/Demo/BSF/WorkOrderReport.py", line 225, in login1 _session.get(url) File "C:\Users*\AppData\Roaming\Python\Python38\site-packages\requests\sessions.py", line 555, in get return self.request('GET', url, kwargs) File "C:\Users**\AppData\Roaming\Python\Python38\site-packages\requests\sessions.py", line 542, in request resp = self.send(prep, *send_kwargs) File "C:\Users*\AppData\Roaming\Python\Python38\site-packages\requests\sessions.py", line 655, in send r = adapter.send(request, kwargs) File "C:\Users**\AppData\Roaming\Python\Python38\site-packages\requests\adapters.py", line 516, in send raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: HTTPConnectionPool(host='211.138.236.215', port=9081): Max retries exceeded with url: /IOMPROJ/logon.jsp (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x0000014B372DC160>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。'))

Process finished with exit code 1

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/100148
 
1182 次点击