Commit ·
101de00
1
Parent(s): cf356ad
commmit Dockerfile
Browse filesFiles changed (2)
- Dockerfile+14-1
- selimium_try.py+12-20
1FROM ubuntu:latest1234567891011121314# Use a Python base image with Playwright pre-installedFROM python:3.9-slim-buster# Install Playwright and its dependenciesRUN pip install playwright && playwright install chromium# Set the working directoryWORKDIR /app# Copy the Python script into the containerCOPY selimium_try.py /app/# Command to run the Python scriptCMD ["python", "selimium_try.py"]
1234567891011121314151617181920212223import gradio as grfrom playwright.sync_api import sync_playwrightdef get_html_from_url(url):try:with sync_playwright() as p:browser = p.chromium.launch()page = browser.new_page()page.goto(url)html = page.content()browser.close()return htmlexcept Exception as e:return f"Error: {e}"iface = gr.Interface(fn=get_html_from_url,inputs=gr.Textbox(lines=2, placeholder="Enter URL here..."),outputs=gr.Textbox(lines=20, placeholder="HTML will appear here..."),title="URL to HTML Fetcher",)iface.launch(share=True)123456789101112131415from playwright.sync_api import sync_playwrightdef get_youtube_html(url="https://www.youtube.com"):"""Fetches the HTML content of a YouTube page using Playwright."""with sync_playwright() as p:browser = p.chromium.launch()page = browser.new_page()page.goto(url)html = page.content()browser.close()return htmlif __name__ == "__main__":html_content = get_youtube_html()print(html_content)
Dockerfile+14-1
selimium_try.py+12-20