Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,25 +13,30 @@ def scrape(url, tags):
|
|
| 13 |
all_data.append(f"Results for <{tag}>:\n" + "\n".join(data))
|
| 14 |
return "\n\n".join(all_data) if all_data else "No data found!"
|
| 15 |
|
| 16 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
with gr.Blocks(css="""
|
| 18 |
body {
|
| 19 |
background: linear-gradient(135deg, #89f7fe, #66a6ff);
|
| 20 |
font-family: 'Arial', sans-serif;
|
| 21 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
.glass-card {
|
| 23 |
background: rgba(255, 255, 255, 0.15);
|
| 24 |
backdrop-filter: blur(20px);
|
| 25 |
border-radius: 25px;
|
| 26 |
padding: 25px;
|
|
|
|
| 27 |
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
|
| 28 |
border: 1px solid rgba(255, 255, 255, 0.18);
|
| 29 |
}
|
| 30 |
-
h1 {
|
| 31 |
-
color: #fff;
|
| 32 |
-
text-align: center;
|
| 33 |
-
text-shadow: 1px 1px 8px rgba(0,0,0,0.3);
|
| 34 |
-
}
|
| 35 |
.gr-button {
|
| 36 |
background: rgba(255, 255, 255, 0.3) !important;
|
| 37 |
color: #000 !important;
|
|
@@ -45,10 +50,6 @@ h1 {
|
|
| 45 |
color: #222 !important;
|
| 46 |
transform: scale(1.05);
|
| 47 |
}
|
| 48 |
-
.gr-textbox {
|
| 49 |
-
border-radius: 15px !important;
|
| 50 |
-
padding: 10px !important;
|
| 51 |
-
}
|
| 52 |
.output-box {
|
| 53 |
max-height: 400px;
|
| 54 |
overflow-y: auto;
|
|
@@ -60,34 +61,36 @@ h1 {
|
|
| 60 |
|
| 61 |
with gr.Row():
|
| 62 |
with gr.Column():
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
|
|
|
| 76 |
with gr.Column():
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
|
|
|
| 80 |
|
| 81 |
-
# Tag
|
| 82 |
-
h1_btn.click(
|
| 83 |
-
h2_btn.click(
|
| 84 |
-
h3_btn.click(
|
| 85 |
-
all_btn.click(
|
| 86 |
|
| 87 |
-
# Scrape button
|
| 88 |
scrape_btn.click(scrape, inputs=[url_input, tag_input], outputs=output)
|
| 89 |
|
| 90 |
-
# Copy button
|
| 91 |
copy_btn.click(lambda x: x, inputs=output, outputs=None)
|
| 92 |
|
| 93 |
demo.launch()
|
|
|
|
| 13 |
all_data.append(f"Results for <{tag}>:\n" + "\n".join(data))
|
| 14 |
return "\n\n".join(all_data) if all_data else "No data found!"
|
| 15 |
|
| 16 |
+
# Function to set tag input
|
| 17 |
+
def set_tag(tag):
|
| 18 |
+
return tag
|
| 19 |
+
|
| 20 |
+
# Gradio interface
|
| 21 |
with gr.Blocks(css="""
|
| 22 |
body {
|
| 23 |
background: linear-gradient(135deg, #89f7fe, #66a6ff);
|
| 24 |
font-family: 'Arial', sans-serif;
|
| 25 |
}
|
| 26 |
+
h1 {
|
| 27 |
+
color: #fff;
|
| 28 |
+
text-align: center;
|
| 29 |
+
text-shadow: 1px 1px 8px rgba(0,0,0,0.3);
|
| 30 |
+
}
|
| 31 |
.glass-card {
|
| 32 |
background: rgba(255, 255, 255, 0.15);
|
| 33 |
backdrop-filter: blur(20px);
|
| 34 |
border-radius: 25px;
|
| 35 |
padding: 25px;
|
| 36 |
+
margin: 10px 0;
|
| 37 |
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
|
| 38 |
border: 1px solid rgba(255, 255, 255, 0.18);
|
| 39 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
.gr-button {
|
| 41 |
background: rgba(255, 255, 255, 0.3) !important;
|
| 42 |
color: #000 !important;
|
|
|
|
| 50 |
color: #222 !important;
|
| 51 |
transform: scale(1.05);
|
| 52 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
.output-box {
|
| 54 |
max-height: 400px;
|
| 55 |
overflow-y: auto;
|
|
|
|
| 61 |
|
| 62 |
with gr.Row():
|
| 63 |
with gr.Column():
|
| 64 |
+
# Glass card using HTML
|
| 65 |
+
gr.HTML("""
|
| 66 |
+
<div class="glass-card">
|
| 67 |
+
""")
|
| 68 |
+
url_input = gr.Textbox(label="Enter Blog URL", placeholder="https://example.com")
|
| 69 |
+
tag_input = gr.Textbox(label="Enter Tags (comma separated, e.g., h1,h2,h3)", value="h2")
|
| 70 |
+
with gr.Row():
|
| 71 |
+
h1_btn = gr.Button("h1")
|
| 72 |
+
h2_btn = gr.Button("h2")
|
| 73 |
+
h3_btn = gr.Button("h3")
|
| 74 |
+
all_btn = gr.Button("h1,h2,h3")
|
| 75 |
+
scrape_btn = gr.Button("Scrape Blog")
|
| 76 |
+
gr.HTML("</div>")
|
| 77 |
+
|
| 78 |
with gr.Column():
|
| 79 |
+
gr.HTML('<div class="glass-card output-box">')
|
| 80 |
+
output = gr.Textbox(label="Scraped Titles", interactive=False)
|
| 81 |
+
copy_btn = gr.Button("Copy to Clipboard")
|
| 82 |
+
gr.HTML('</div>')
|
| 83 |
|
| 84 |
+
# Tag buttons click events
|
| 85 |
+
h1_btn.click(set_tag, inputs=[], outputs=tag_input, args=["h1"])
|
| 86 |
+
h2_btn.click(set_tag, inputs=[], outputs=tag_input, args=["h2"])
|
| 87 |
+
h3_btn.click(set_tag, inputs=[], outputs=tag_input, args=["h3"])
|
| 88 |
+
all_btn.click(set_tag, inputs=[], outputs=tag_input, args=["h1,h2,h3"])
|
| 89 |
|
| 90 |
+
# Scrape button
|
| 91 |
scrape_btn.click(scrape, inputs=[url_input, tag_input], outputs=output)
|
| 92 |
|
| 93 |
+
# Copy button
|
| 94 |
copy_btn.click(lambda x: x, inputs=output, outputs=None)
|
| 95 |
|
| 96 |
demo.launch()
|