Python 代理设置 [英] Python Proxy Settings

查看:58
本文介绍了Python 代理设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了维基百科模块,您可以在其中获取有关维基百科上该主题的信息.当我运行代码时,由于代理而无法连接.当我将 PC 连接到无代理网络时,它正在工作.在使用 Beautiful Soup 模块进行抓取时也发生了这种情况.我试图设置环境变量像 http://username:password@proxy_url:port 但是当运行IDLE 中的代码不起作用.请帮忙.

I was using the wikipedia module in which you can get the information that is present about that topic on wikipedia. When I run the code it is unable to connect because of proxy. When I connected PC to a proxy free network it's working. It also happened while using the Beautiful soup module for scraping. I have tried to set environment variable like http://username:password@proxy_url:port but when the run the code in IDLE it's not working. Please help.

推荐答案

它奏效了:

import os
os.environ["HTTPS_PROXY"] = "http://user_id:pass@proxy:port"

这篇关于Python 代理设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆