您如何在boto3中使用HTTP/HTTPS代理? [英] How do you use an HTTP/HTTPS proxy with boto3?

查看:348
本文介绍了您如何在boto3中使用HTTP/HTTPS代理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很简单,可以在打开连接时使用proxyproxy_portproxy_userproxy_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屋!

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