Skip to content

Instantly share code, notes, and snippets.

@Mgancita
Created February 13, 2022 20:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mgancita/63e8fa3c3178600ac537ebba9a692f16 to your computer and use it in GitHub Desktop.
Save Mgancita/63e8fa3c3178600ac537ebba9a692f16 to your computer and use it in GitHub Desktop.
import httpx
def get_page(url):
with httpx.Client() as client:
r = client.get(url)
return r.text
print(get_page('https://www.example.org/'))
# '<!doctype html>\n<html>\n<head>\n<title>Example Domain</title>...'
async def get_page(url):
async with httpx.AsyncClient() as client:
r = await client.get(url)
return r.text
print(get_page('https://www.example.org/'))
# '<!doctype html>\n<html>\n<head>\n<title>Example Domain</title>...'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment