-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(.env.example): add support for SERVICE environment variable
* feat(README.md): update tool description to support both SIM24 and 1&1 Unlimited-Demand tariffs * feat(docker-entrypoint.sh): add SERVICE variable to .env file creation * feat(main.py): add logging filter for different services and update main function to support multiple services
- Loading branch information
Showing
6 changed files
with
171 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
SERVICE="" # 1und1, sim24 | ||
USERNAME="" | ||
PASSWORD="" | ||
CHECK_INTERVAL=300 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import time | ||
from playwright.sync_api import sync_playwright | ||
import logging | ||
|
||
def check_1und1(username, password): | ||
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(message)s") | ||
|
||
try: | ||
with sync_playwright() as p: | ||
browser = p.chromium.launch(headless=False) | ||
page = browser.new_page() | ||
|
||
logging.info("Öffne Login-Seite...") | ||
page.goto('https://account.1und1.de/') | ||
|
||
logging.info("Führe Login durch...") | ||
page.fill('#login-form-user', username) | ||
page.fill('#login-form-password', password) | ||
|
||
page.click('#login-button') | ||
logging.info("Login erfolgreich") | ||
|
||
logging.info("Cookies ablehnen...") | ||
try: | ||
page.click('#consent_wall_optout') | ||
except: | ||
logging.info("Cookie-Banner nicht vorhanden oder bereits geschlossen.") | ||
|
||
logging.info("Weiterleitung zu Verbrauchsübersicht...") | ||
page.goto('https://control-center.1und1.de/usages.html') | ||
|
||
time.sleep(3) | ||
|
||
page.wait_for_selector('div[data-testid="usage-volume-used"] strong') | ||
used_data = page.locator('div[data-testid="usage-volume-used"] strong').nth(-1).text_content() | ||
if used_data: | ||
logging.info(f"Verbrauchte Daten: {used_data}") | ||
else: | ||
logging.warning("Verbrauchsdaten nicht gefunden.") | ||
|
||
button = page.locator('button:has-text("+1 GB")') | ||
if button: | ||
is_disabled = button.get_attribute('disabled') is not None | ||
if is_disabled: | ||
logging.info("Button gefunden, aber er ist deaktiviert.") | ||
else: | ||
logging.info("Button gefunden und aktiv. Versuche zu klicken...") | ||
button.click() | ||
logging.info("Button erfolgreich geklickt.") | ||
time.sleep(3) | ||
confirm_button = page.locator('button:has-text("Ok")') | ||
if confirm_button: | ||
confirm_button.click() | ||
logging.info("Bestätigungsdialog erfolgreich geschlossen.") | ||
|
||
else: | ||
logging.warning("Button '+1 GB' nicht gefunden.") | ||
|
||
logging.info("Schließe Browser.") | ||
browser.close() | ||
|
||
except Exception as e: | ||
logging.error(f"Fehler bei der Ausführung: {str(e)}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
from playwright.sync_api import sync_playwright | ||
import logging | ||
|
||
def check_sim24(username, password): | ||
try: | ||
with sync_playwright() as p: | ||
browser = p.chromium.launch(headless=True) | ||
page = browser.new_page() | ||
|
||
logging.info("Öffne Login-Seite...") | ||
page.goto('https://service.sim24.de/mytariff/invoice/showGprsDataUsage') | ||
|
||
logging.info("Führe Login durch...") | ||
page.fill('input[name="UserLoginType[alias]"]', username) | ||
page.fill('input[name="UserLoginType[password]"]', password) | ||
|
||
page.click('a.c-button.submitOnEnter[title="Login"]') | ||
|
||
logging.info("Deny Cookies...") | ||
consent_button = page.query_selector('#consent_wall_optout') | ||
if consent_button and consent_button.is_visible(): | ||
consent_button.click() | ||
else: | ||
logging.info("Consent button not visible, skipping...") | ||
|
||
logging.info("Suche nach Button...") | ||
try: | ||
button = page.wait_for_selector('#ButtonBuchen-ChangeServiceType-showGprsDataUsage-0V5I3', timeout=10000) | ||
stats = page.wait_for_selector('.dataUsageBar-info-numbers', timeout=10000) | ||
|
||
if stats: | ||
used_data = stats.query_selector('.font-weight-bold').inner_text() | ||
total_data = stats.query_selector('.l-txt-small').inner_text().replace('von', '').strip() | ||
logging.info(f"Verbrauchte Daten: {used_data} von {total_data}") | ||
|
||
if button: | ||
is_disabled = button.get_attribute('disabled') is not None | ||
|
||
if is_disabled: | ||
logging.info("Button gefunden, aber deaktiviert") | ||
else: | ||
logging.info("Button gefunden und aktiv - Klicke...") | ||
button.click() | ||
logging.info("Button erfolgreich geklickt") | ||
|
||
page.click('#ButtonAktivieren-ChangeServiceType-getChangeServiceInfo-1V5I3') | ||
|
||
logging.info("Prozess erfolgreich beendet") | ||
return | ||
else: | ||
logging.warning("Button nicht gefunden") | ||
|
||
except Exception as e: | ||
logging.warning(f"Button nicht gefunden oder nicht klickbar: {str(e)}") | ||
|
||
logging.info("Schließe Browser") | ||
browser.close() | ||
|
||
except Exception as e: | ||
logging.error(f"Fehler bei der Ausführung: {str(e)}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters