Make async HTTP requests with HTTPX

PHOTO EMBED

Mon Sep 19 2022 13:38:35 GMT+0000 (Coordinated Universal Time)

Saved by @aguest #python #async #requests

import asyncio

import httpx


async def main():
	async with httpx.AsyncClient() as client:
		resp = await client.get("https://python.org")
        http_text = await resp.text()
		print(http_text)


loop = asyncio.get_event_loop()
loop.run_until_complete(main())
content_copyCOPY