mirror of
https://github.com/serega404/MetricAliexpressExchangeRate.git
synced 2025-04-21 14:10:45 +03:00
Compare commits
2 Commits
679e5c37f3
...
9e841014de
Author | SHA1 | Date | |
---|---|---|---|
9e841014de | |||
8bbd9a2ff3 |
6
.gitattributes
vendored
Normal file
6
.gitattributes
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
#
|
||||
# https://help.github.com/articles/dealing-with-line-endings/
|
||||
#
|
||||
# These are explicitly windows files and should use crlf
|
||||
|
||||
* text=auto eol=lf
|
13
main.py
13
main.py
@ -20,7 +20,7 @@ if (site.status_code != 200):
|
||||
|
||||
soup = BeautifulSoup(site.text, "html.parser")
|
||||
|
||||
for tag in soup.find_all("span", class_="product-price-current"):
|
||||
for tag in soup.find_all("div", class_="snow-price_SnowPrice__mainS__ugww0l"):
|
||||
KursAli = (''.join(x for x in tag.text if (x.isdigit() or x == ','))).replace(',','.')
|
||||
|
||||
print("Курс Ali: " + KursAli)
|
||||
@ -36,6 +36,8 @@ if (site.status_code != 200):
|
||||
KursCBRF = str(json.loads(site.text)["Valute"]["USD"]["Value"])
|
||||
print("Курс ЦБ РФ: " + KursCBRF)
|
||||
|
||||
print("Разница Ali и CBRF", round(max(float(KursAli), float(KursCBRF)) - min(float(KursAli), float(KursCBRF)), 2))
|
||||
|
||||
# Send metrics ↓
|
||||
|
||||
url = MetricServerURL + 'api/v1/import/csv?format=1:label:source,2:metric:exchange_usd_rub'
|
||||
@ -52,4 +54,11 @@ if KursAli != '':
|
||||
if (x.status_code != 200 and x.status_code != 204):
|
||||
print("Не удалось отправить метрику: " + str(x.status_code))
|
||||
else:
|
||||
print("Курс Али пуст")
|
||||
print("Курс Али пуст")
|
||||
|
||||
if KursCBRF != '' and KursAli != '':
|
||||
x = requests.post(url, "Diff Ali CBRF," + str(round(max(float(KursAli), float(KursCBRF)) - min(float(KursAli), float(KursCBRF)), 2)))
|
||||
if (x.status_code != 200 and x.status_code != 204):
|
||||
print("Не удалось отправить метрику: " + str(x.status_code))
|
||||
else:
|
||||
print("Один из курсов пуст")
|
Loading…
x
Reference in New Issue
Block a user