-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbbEurobit.py
66 lines (58 loc) · 1.57 KB
/
bbEurobit.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Benzín Brno - Eurobit - NATURAL 95 - pumpa: 'Brno - Podolí' - bbEurobit.py
# https://www.eurobit.cz/ceny
# 14.05.2023 - 1.verze
import asyncio
from bbCena import tF
# extract - stahne stranku
async def extract(url=''):
from bbGetPage import GetPage
import sys
import re
page_source = await GetPage(url)
# Parsuj cenu pomoci RegEx
item = str(page_source)
# print(item) #debug
# https://regex101.com/r/H4q4sn/5
# "Brno - Podolí","chrudim1Natural":"35,90 Kč"}
try:
item = re.search(r'\"Brno - Podolí\",\"chrudim1Natural\":\"(\d+,\d*)', item)
if not (item):
return 0
# prevedu na string
item = str(item.group(1))
item = item.replace(",", ".")
# print('item', item, type(item)) # debug
except: # catch *all* exceptions # pylint: disable=bare-except
e = sys.exc_info()[0]
print("Error v bbEurobit.py: ", e)
item = '0'
# Cena
# print('item', item, type(item))
item = float(item)
Cena = item
return Cena
# test function
async def tEuroB(url=''):
from bbCFG import brint, bbProduct, bbNoUrl
brint('tEuroB: url', url)
if bbProduct and (url != bbNoUrl):
return await EuroB(url)
else:
return 17.5
# EuroB
async def EuroB(url=''):
url = r'https://www.eurobit.cz/ceny'
Cena = await extract(url)
return Cena
# main
async def bbEurobit_main():
print('tEuroB(): ', await tEuroB())
print('OkDone.')
# __name__
if __name__ == '__main__':
asyncio.run(bbEurobit_main())
# Notes
# https://www.eurobit.cz/ceny
# "title":"Brno - Podolí","chrudim1Natural":"35,90 Kč"}
# History
# 14.05.2023 - 1.verze