-
Notifications
You must be signed in to change notification settings - Fork 0
/
data_class.py
37 lines (28 loc) · 1010 Bytes
/
data_class.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import requests, json, urls
class Data:
def __init__(self, pages: int):
self.pages = pages
def instant_data(self):
"""This method extracts multi-page instant data."""
data_list = []
for page in range(self.pages):
url = urls.data_url(page)
raw_data = requests.get(url).text
raw_list = json.loads(raw_data)
data_list.append(raw_list)
combined_list = []
for item in data_list:
combined_list.extend(item)
return combined_list
class HData:
def __init__(self, token_id: str, date: str):
self.token_id = token_id
self.date = date
def historical_data(self):
"""This method extracts historical data by token ID and date."""
data_list = []
url = urls.historical_data_url(self.token_id, self.date)
raw_data = requests.get(url).text
raw_list = json.loads(raw_data)
data_list.append(raw_list)
return data_list