Commit
·
101de00
1
Parent(s):
cf356ad
commmit Dockerfile
Browse files- Dockerfile +14 -1
- selimium_try.py +12 -20
Dockerfile
CHANGED
|
@@ -1 +1,14 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use a Python base image with Playwright pre-installed
|
| 2 |
+
FROM python:3.9-slim-buster
|
| 3 |
+
|
| 4 |
+
# Install Playwright and its dependencies
|
| 5 |
+
RUN pip install playwright && playwright install chromium
|
| 6 |
+
|
| 7 |
+
# Set the working directory
|
| 8 |
+
WORKDIR /app
|
| 9 |
+
|
| 10 |
+
# Copy the Python script into the container
|
| 11 |
+
COPY selimium_try.py /app/
|
| 12 |
+
|
| 13 |
+
# Command to run the Python script
|
| 14 |
+
CMD ["python", "selimium_try.py"]
|
selimium_try.py
CHANGED
|
@@ -1,23 +1,15 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
from playwright.sync_api import sync_playwright
|
| 3 |
|
| 4 |
-
def
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
except Exception as e:
|
| 14 |
-
return f"Error: {e}"
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
outputs=gr.Textbox(lines=20, placeholder="HTML will appear here..."),
|
| 20 |
-
title="URL to HTML Fetcher",
|
| 21 |
-
)
|
| 22 |
-
|
| 23 |
-
iface.launch(share=True)
|
|
|
|
|
|
|
| 1 |
from playwright.sync_api import sync_playwright
|
| 2 |
|
| 3 |
+
def get_youtube_html(url="https://www.youtube.com"):
|
| 4 |
+
"""Fetches the HTML content of a YouTube page using Playwright."""
|
| 5 |
+
with sync_playwright() as p:
|
| 6 |
+
browser = p.chromium.launch()
|
| 7 |
+
page = browser.new_page()
|
| 8 |
+
page.goto(url)
|
| 9 |
+
html = page.content()
|
| 10 |
+
browser.close()
|
| 11 |
+
return html
|
|
|
|
|
|
|
| 12 |
|
| 13 |
+
if __name__ == "__main__":
|
| 14 |
+
html_content = get_youtube_html()
|
| 15 |
+
print(html_content)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|