49 lines
1.7 KiB
Python
49 lines
1.7 KiB
Python
import contextlib
|
|
|
|
from playwright.sync_api import sync_playwright, Page
|
|
from time import sleep
|
|
|
|
|
|
@contextlib.contextmanager
|
|
def launch_browser() -> Page:
|
|
with sync_playwright() as playwright:
|
|
with playwright.chromium.launch(headless=False) as browser:
|
|
with browser.new_context() as context:
|
|
with context.new_page() as page:
|
|
yield page
|
|
|
|
|
|
def book_slot():
|
|
with launch_browser() as page:
|
|
page.goto("https://service.berlin.de/dienstleistung/120686/")
|
|
page.get_by_role("complementary").get_by_role("link", name="Termin berlinweit suchen").click()
|
|
|
|
with page.expect_navigation(url='https://service.berlin.de/terminvereinbarung/termin/time/*', timeout=0):
|
|
pass
|
|
|
|
with page.expect_navigation(url='https://service.berlin.de/terminvereinbarung/termin/register/*', timeout=0):
|
|
pass
|
|
|
|
page.get_by_label("Ihr Vor- und Nachname *").fill("Paulina Gutkowska")
|
|
page.get_by_label("Ihre E-Mail Adresse *").fill("gutpaula11@gmail.com")
|
|
if page.is_visible("Ihre Telefonnummer oder Mobilfunknummer *"):
|
|
page.get_by_label("Ihre Telefonnummer oder Mobilfunknummer *").fill("+48501099723")
|
|
page.get_by_role("combobox").select_option("0")
|
|
page.get_by_label(
|
|
"Ich erkläre mich mit den Nutzungsbedingungen einverstanden und akzeptiere diese. (Pflichtangabe. Termineintrag nur bei Einverständnis möglich) *"
|
|
).check()
|
|
|
|
with page.expect_navigation():
|
|
page.get_by_role("button", name="Termin eintragen").click()
|
|
|
|
sleep(10)
|
|
input()
|
|
|
|
|
|
def main():
|
|
book_slot()
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|