python网络登录脚本_如何用python脚本登录到internet?

在尝试使用Python脚本安装matplotlib.pyplot时遇到407 Proxy Authentication Required错误。问题在于需要通过需要用户名和密码的代理进行连接。目前代码无法处理代理认证,导致连接失败。已尝试多次重试安装,但仍然无法成功。该问题可能由于学校网络系统限制导致。
摘要由CSDN通过智能技术生成

我试图用python脚本连接到internet,但是代理需要用户名和密码。我有这两个,但我不知道如何在代码期间登录到代理。在

对我尝试在没有密码的情况下进行连接的反应是:import pip

pip.main(['install', 'matplotlib.pyplot'])

Collecting matplotlib.pyplot

Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Proxy Authentication Required',))': /simple/matplotlib-pyplot/

Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Proxy Authentication Required',))': /simple/matplotlib-pyplot/

Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Proxy Authentication Required',))': /simple/matplotlib-pyplot/

Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Proxy Authentication Required',))': /simple/matplotlib-pyplot/

Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Proxy Authentication Required',))': /simple/matplotlib-pyplot/

Could not find a version that satisfies the requirement matplotlib.pyplot (from versions: )

No matching distribution found for matplotlib.pyplot

Out[3]: 1

如果需要的话,我可以详细说明。

谢谢。在

只是说,这是在一个学校互联网系统(新南威尔士州),所以可能会有一些行动受到限制。在

按照巴斯特尔夫的指示,得到了这个结果;

Traceback (most recent call last):

File "/Users/euanoflynn/anaconda/lib/python3.6/site-packages/requests/packages/urllib3/connection.py", line 141, in _new_conn

(self.host, self.port), self.timeout, **extra_kw)

File "/Users/euanoflynn/anaconda/lib/python3.6/site-packages/requests/packages/urllib3/util/connection.py", line 83, in create_connection

raise err

File "/Users/euanoflynn/anaconda/lib/python3.6/site-packages/requests/packages/urllib3/util/connection.py", line 73, in create_connection

sock.connect(sa)

TimeoutError: [Errno 60] Operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "/Users/euanoflynn/anaconda/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py", line 594, in urlopen

self._prepare_proxy(conn)

File "/Users/euanoflynn/anaconda/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py", line 810, in _prepare_proxy

conn.connect()

File "/Users/euanoflynn/anaconda/lib/python3.6/site-packages/requests/packages/urllib3/connection.py", line 284, in connect

conn = self._new_conn()

File "/Users/euanoflynn/anaconda/lib/python3.6/site-packages/requests/packages/urllib3/connection.py", line 150, in _new_conn

self, "Failed to establish a new connection: %s" % e)

requests.packages.urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 60] Operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "/Users/euanoflynn/anaconda/lib/python3.6/site-packages/requests/adapters.py", line 438, in send

timeout=timeout

File "/Users/euanoflynn/anaconda/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py", line 649, in urlopen

_stacktrace=sys.exc_info()[2])

File "/Users/euanoflynn/anaconda/lib/python3.6/site-packages/requests/packages/urllib3/util/retry.py", line 388, in increment

raise MaxRetryError(_pool, url, error or ResponseError(cause))

requests.packages.urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='finance.yahoo.com', port=443): Max retries exceeded with url: / (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError(': Failed to establish a new connection: [Errno 60] Operation timed out',)))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "/Users/euanoflynn/anaconda/tests/Tests.py", line 22, in

r = requests.get("https://finance.yahoo.com", proxies=proxies)

File "/Users/euanoflynn/anaconda/lib/python3.6/site-packages/requests/api.py", line 72, in get

return request('get', url, params=params, **kwargs)

File "/Users/euanoflynn/anaconda/lib/python3.6/site-packages/requests/api.py", line 58, in request

return session.request(method=method, url=url, **kwargs)

File "/Users/euanoflynn/anaconda/lib/python3.6/site-packages/requests/sessions.py", line 518, in request

resp = self.send(prep, **send_kwargs)

File "/Users/euanoflynn/anaconda/lib/python3.6/site-packages/requests/sessions.py", line 639, in send

r = adapter.send(request, **kwargs)

File "/Users/euanoflynn/anaconda/lib/python3.6/site-packages/requests/adapters.py", line 500, in send

raise ProxyError(e, request=request)

requests.exceptions.ProxyError: HTTPSConnectionPool(host='finance.yahoo.com', port=443): Max retries exceeded with url: / (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError(': Failed to establish a new connection: [Errno 60] Operation timed out',)))

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值