Created
February 13, 2022 20:46
-
-
Save Mgancita/63e8fa3c3178600ac537ebba9a692f16 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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