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

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

问题描述

在旧的 boto 库上很简单,可以使用 proxyproxy_portproxy_user 和 <打开连接时的 code>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 配置中接受 proxys 参数.

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天全站免登陆