Created
June 9, 2023 13:29
-
-
Save fancellu/02a2817f77cc069957c62ae16eeee75a to your computer and use it in GitHub Desktop.
Retrieves a random quote, uses requests, json and pydantic
This file contains hidden or 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 requests as requests | |
from requests import Response | |
from pydantic import BaseModel | |
class Quote(BaseModel): | |
content: str | |
author: str | |
response: Response = requests.get('https://api.quotable.io/random') | |
quote: Quote = Quote.parse_raw(response.text) | |
print(quote) |
This file contains hidden or 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
requests~=2.31.0 | |
pydantic~=1.10.9 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment