aiohttpx
A Python Wrapper for httpx that combines the httpx.AsyncClient with the httpx.Client to allow both async and sync requests
Latest Version: 
Installation
pip install --upgrade aiohttpx
pip install --upgrade git+https://github.com/trisongz/aiohttpx
Usage
aiohttpx
is a wrapper around httpx
that provides a unified async
+ sync
interface for making HTTP requests. This is useful for making HTTP requests in both async
and sync
codebases.
Additionally, it includes a ProxyClient
that can be used for scraping / high volume requests that would otherwise be blocked by the target server by using a rotating proxy pool through AWS API Gateway
.
import asyncio
import aiohttpx
async def test_requests():
async with aiohttpx.Client() as client:
response = await client.async_get("https://httpbin.org/get")
print(response.json())
response = client.get("https://httpbin.org/get")
print(response.json())
with aiohttpx.Client() as client:
response = await client.async_get("https://httpbin.org/get")
print(response.json())
response = client.get("https://httpbin.org/get")
print(response.json())
async def test_proxies():
base_url = "https://www.google.com"
async with aiohttpx.ProxyClient(base_url = base_url) as client:
response = await client.async_get(
"/search",
params = {"q": "httpx"},
soup_enabled = True
)
print(response.soup)
print(response.soup.title.text)
response = client.get(
"/search",
params = {"q": "httpx"},
soup_enabled = True
)
print(response.soup)
print(response.soup.title.text)
async def run_tests():
await asyncio.gather(
test_requests(),
test_proxies()
)
asyncio.run(run_tests())