您如何在boto3中使用HTTP/HTTPS代理? [英] How do you use an HTTP/HTTPS proxy with boto3?
问题描述
很简单,可以在打开连接时使用proxy
,proxy_port
,proxy_user
和proxy_pass
参数.但是,我找不到在boto3上以编程方式定义代理参数的任何等效方法. :(
On the old boto
library is was simple enough to use the proxy
, proxy_port
, proxy_user
and proxy_pass
parameters when you open a connection. However, I could not find any equivalent way of programmatically define the proxy parameters on boto3. :(
推荐答案
从最低版本1.5.79开始,botocore在botocore配置中接受proxies
自变量.
As of at least version 1.5.79, botocore accepts a proxies
argument in the botocore config.
例如
import boto3
from botocore.config import Config
boto3.resource('s3', config=Config(proxies={'https': 'foo.bar:3128'}))
boto3资源 https://boto3.readthedocs.io/en/latest/reference/core/session.html#boto3.session.Session.resource
botocore配置 https://botocore.readthedocs.io/en/stable/reference/config.html#botocore.config.Config
这篇关于您如何在boto3中使用HTTP/HTTPS代理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!