Base of parser (currency part)
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,2 +1,2 @@
|
|||||||
|
.venv
|
||||||
.codegpt
|
.codegpt
|
||||||
20
parser/currency.py
Normal file
20
parser/currency.py
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import requests
|
||||||
|
import json
|
||||||
|
|
||||||
|
url = "https://www.cbr-xml-daily.ru/daily_json.js"
|
||||||
|
|
||||||
|
class Currency:
|
||||||
|
def __init__(self, code: str):
|
||||||
|
self.name = code
|
||||||
|
self.status = True
|
||||||
|
response = requests.get(url)
|
||||||
|
response.raise_for_status() # Проверяем успешность запроса
|
||||||
|
try:
|
||||||
|
# Парсим JSON-данные
|
||||||
|
data = response.json()
|
||||||
|
self.yen_rate = data["Valute"][code]["Value"]
|
||||||
|
self.yen_nominal = data["Valute"][code]["Nominal"]
|
||||||
|
except:
|
||||||
|
self.status = False
|
||||||
|
|
||||||
|
obj = Currency("JPY")
|
||||||
3
parser/requirements.txt
Normal file
3
parser/requirements.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
bs4==0.0.2
|
||||||
|
requests==2.32.3
|
||||||
|
|
||||||
Reference in New Issue
Block a user