如何为python http连接指定经过身份验证的代理? [英] How to specify an authenticated proxy for a python http connection?

查看:147
本文介绍了如何为python http连接指定经过身份验证的代理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在python中为http连接指定具有用户名和密码的代理的最佳方法是什么?

What's the best way to specify a proxy with username and password for an http connection in python?

推荐答案

使用此:

import requests

proxies = {"http":"http://username:password@proxy_ip:proxy_port"}

r = requests.get("http://www.example.com/", proxies=proxies)

print(r.content)

我认为它比使用 urllib 简单得多。我不明白为什么人们喜欢使用 urllib 这么多。

I think it's much simpler than using urllib. I don't understand why people love using urllib so much.

这篇关于如何为python http连接指定经过身份验证的代理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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