通过代理连接发送带有标题的aiohttp发布请求 [英] send aiohttp post request with headers through proxy connection
本文介绍了通过代理连接发送带有标题的aiohttp发布请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我现在拥有的东西(Python 3.4):
r = aiohttp.request('post',URL, params = None,数据=值,标题=标题)
文档:
conn = aiohttp.ProxyConnector(proxy = http://some.proxy.com)
r = await aiohttp.get('http://python.org',connector = conn)
那么,我应该如何通过与aiohttp的代理连接发送带有标头的发帖请求? p>
谢谢。
解决方案
connector = aiohttp.ProxyConnector(proxy = http://some.proxy.com)
会话= aiohttp.ClientSession(connector = connector)
与session.post( http:// example。 com / post,data = b binary data)as resp:
print(resp.status)
session.close()
What I have now (Python 3.4):
r = yield from aiohttp.request('post', URL, params=None, data=values, headers=headers)
What is in the documentation:
conn = aiohttp.ProxyConnector(proxy="http://some.proxy.com")
r = await aiohttp.get('http://python.org', connector=conn)
So, how should I send a post request with headers through proxy connection with aiohttp?
Thanks.
解决方案
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()
这篇关于通过代理连接发送带有标题的aiohttp发布请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文