Add the api fetcher.

This commit is contained in:
2023-06-18 09:30:55 +03:00
parent 396d0c0722
commit 940a1e9636
2 changed files with 13 additions and 0 deletions
+13
View File
@@ -0,0 +1,13 @@
import requests
class ApiFetcher:
"""The handler of response."""
def __init__(self, config):
self.config = config
def get(self, url) -> (int, dict|None):
headers = self.config.get_headers()
response = requests.get(url, headers=headers)
if response.status_code != 200:
return (response.status_code, None)
return (response.status_code, response.json())