37 lines
961 B
Python
37 lines
961 B
Python
from typing import Union
|
|
|
|
from bs4 import BeautifulSoup
|
|
from selenium.webdriver import Chrome
|
|
from selenium.webdriver.chrome.options import Options
|
|
|
|
|
|
def get_balance(card_id: Union[str, int]) -> Union[str, None]:
|
|
chrome_options = Options()
|
|
chrome_options.add_argument('--no-sandbox')
|
|
chrome_options.add_argument('--headless')
|
|
chrome_options.add_argument('--disable-dev-shm-usage')
|
|
|
|
driver = Chrome(options=chrome_options)
|
|
|
|
driver.get(f"https://bwtaqua.com.ua/card-topup/?id={card_id}")
|
|
|
|
html = driver.page_source
|
|
|
|
soup = BeautifulSoup(html, "html.parser")
|
|
|
|
return (
|
|
(
|
|
soup.find_all(
|
|
"h3",
|
|
class_="headline headline_center headline_pink js-payment-balance",
|
|
)[0].getText()
|
|
)
|
|
.replace("Твій баланс ", "")
|
|
.replace(" л", "")
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
card = input("Type your card ID: ")
|
|
print(get_balance(card))
|