From a146c7d82e25bee4a75e8fc770596bedc159ae09 Mon Sep 17 00:00:00 2001 From: Daniel Roth Date: Thu, 19 Mar 2026 16:45:53 +0000 Subject: [PATCH] go to pas hub with playwright --- .devcontainer/backend/requirements.txt | 1 + backend/pashub_fetcher/handler/Dockerfile | 4 ++-- backend/pashub_fetcher/handler/handler.py | 12 +++++++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.devcontainer/backend/requirements.txt b/.devcontainer/backend/requirements.txt index 5cd40ced..d7afa6a2 100644 --- a/.devcontainer/backend/requirements.txt +++ b/.devcontainer/backend/requirements.txt @@ -6,6 +6,7 @@ psycopg2-binary==2.9.10 python-jose==3.3.0 cryptography==43.0.3 mangum==0.19.0 +playwright==1.58.0 # AWS boto3==1.35.44 # Data diff --git a/backend/pashub_fetcher/handler/Dockerfile b/backend/pashub_fetcher/handler/Dockerfile index 1534afdb..2128d12c 100644 --- a/backend/pashub_fetcher/handler/Dockerfile +++ b/backend/pashub_fetcher/handler/Dockerfile @@ -1,11 +1,11 @@ -FROM mcr.microsoft.com/playwright/python:v1.42.0 +FROM mcr.microsoft.com/playwright/python:v1.58.0-jammy # Install AWS Lambda RIE ADD https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie /usr/local/bin/aws-lambda-rie RUN chmod +x /usr/local/bin/aws-lambda-rie # Install Lambda runtime client -RUN pip install awslambdaric +RUN pip install awslambdaric playwright==1.58.0 # Set working directory (Lambda task root) WORKDIR /var/task diff --git a/backend/pashub_fetcher/handler/handler.py b/backend/pashub_fetcher/handler/handler.py index 00fbd6b5..2fe2af1d 100644 --- a/backend/pashub_fetcher/handler/handler.py +++ b/backend/pashub_fetcher/handler/handler.py @@ -1,5 +1,7 @@ from typing import Any, Mapping +from playwright.sync_api import sync_playwright + from utils.logger import setup_logger @@ -7,4 +9,12 @@ logger = setup_logger() def handler(event: Mapping[str, Any], context: Any) -> None: - logger.info("Received message") + logger.info("Starting Playwright flow") + + with sync_playwright() as p: + browser = p.chromium.launch(headless=True) + page = browser.new_page() + + page.goto("https://pashub.net/") + + logger.info(f"Page title: {page.title()}")