Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,7 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
2 |
|
3 |
def get_web_page_data(url):
|
4 |
response = requests.get(url)
|
@@ -6,25 +9,15 @@ def get_web_page_data(url):
|
|
6 |
return parser.html
|
7 |
|
8 |
def copy_to_clipboard(text):
|
9 |
-
import pyperclip
|
10 |
pyperclip.copy(text)
|
11 |
return "Copied to clipboard!"
|
12 |
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
title="Web Page Data Extractor",
|
18 |
-
description="Enter a URL to extract its web page data"
|
19 |
-
)
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
fn=get_web_page_data,
|
24 |
-
inputs=["text", copy_btn],
|
25 |
-
outputs=["text"],
|
26 |
-
title="Web Page Data Extractor",
|
27 |
-
description="Enter a URL to extract its web page data"
|
28 |
-
)
|
29 |
|
30 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
import requests
|
3 |
+
from selectolax.parser import HTMLParser
|
4 |
+
import pyperclip
|
5 |
|
6 |
def get_web_page_data(url):
|
7 |
response = requests.get(url)
|
|
|
9 |
return parser.html
|
10 |
|
11 |
def copy_to_clipboard(text):
|
|
|
12 |
pyperclip.copy(text)
|
13 |
return "Copied to clipboard!"
|
14 |
|
15 |
+
with gr.Blocks() as demo:
|
16 |
+
url_input = gr.Textbox(label="Enter a URL")
|
17 |
+
output = gr.Textbox(label="Web Page Data")
|
18 |
+
copy_output = gr.Textbox(label="Copy Status")
|
|
|
|
|
|
|
19 |
|
20 |
+
gr.Button("Get Web Page Data").click(get_web_page_data, inputs=url_input, outputs=output)
|
21 |
+
gr.Button("Copy to Clipboard").click(copy_to_clipboard, inputs=output, outputs=copy_output)
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
demo.launch()
|