Skip to content Skip to sidebar Skip to footer

Send Aiohttp Post Request With Headers Through Proxy Connection

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(

Solution 1:

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

session.close()

Solution 2:

you can use this:

importaiohttpconn= aiohttp.ProxyConnector(proxy="http://some.proxy.com")

r = await aiohttp.post('http://python.org', connector=conn, data=b"hello", headers={})

or

import aiohttp

from aiohttp importrequestconn= aiohttp.ProxyConnector(proxy="http://some.proxy.com")

r = await request('post','http://python.org', connector=conn, data=b"hello", headers={})

Post a Comment for "Send Aiohttp Post Request With Headers Through Proxy Connection"