This repository has been archived on 2024-08-21. You can view files and clone it, but cannot push or open issues or pull requests.
BWTAqua/modules/bwt_scrape.py

37 lines
961 B
Python
Raw Normal View History

2023-08-23 15:13:17 +03:00
from typing import Union
from bs4 import BeautifulSoup
2023-08-23 15:19:39 +03:00
from selenium.webdriver import Chrome
from selenium.webdriver.chrome.options import Options
2023-08-23 15:13:17 +03:00
def get_balance(card_id: Union[str, int]) -> Union[str, None]:
2023-08-23 15:19:39 +03:00
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)
2023-08-23 15:13:17 +03:00
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))