python - 通过代理连接发送带有 header 的 aiohttp post 请求

标签 python python-3.x proxy aiohttp

我现在拥有的(Python 3.4):

r = yield from aiohttp.request('post', URL, params=None, data=values, headers=headers)

documentation 里有什么:

conn = aiohttp.ProxyConnector(proxy="http://some.proxy.com")
r = await aiohttp.get('http://python.org', connector=conn)

那么,我应该如何通过 aiohttp 的代理连接发送带有 header 的 post 请求?

谢谢。

最佳答案

connector = aiohttp.ProxyConnector(proxy="http://some.proxy.com")
session = aiohttp.ClientSession(connector=connector)
async with session.post("http://example.com/post", data=b"binary data") as resp:
    print(resp.status)

session.close()

关于python - 通过代理连接发送带有 header 的 aiohttp post 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35132127/

相关文章:

Python urllib 向 Google 网站请求速度缓慢

imp.new_module() 的 Python importlib 模拟

python - Flask 应用程序因多个进程而锁定

c# - 使用 Tor 作为代理

python - Pandas复制后如何修改数据?

python - matplotlib 使用什么 GUI 库?

python - %matplotlib 笔记本显示空白直方图

python - 通过套接字发送文件

android - 如何从代理后面的 Android 应用程序通过 HTTPS 访问服务?

android - 禁用通过代理或 root 设备的 http 调用