simran40 commited on
Commit
e0fa4d6
·
verified ·
1 Parent(s): c913ec4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -33
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
- # Gradio Blocks with updated UI
 
 
 
 
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
- with gr.Group(css_class="glass-card"):
64
- url_input = gr.Textbox(label="Enter Blog URL", placeholder="https://example.com")
65
- tag_input = gr.Textbox(label="Enter Tags (comma separated, e.g., h1,h2,h3)", value="h2")
66
-
67
- # Tag buttons for quick selection
68
- with gr.Row():
69
- h1_btn = gr.Button("h1")
70
- h2_btn = gr.Button("h2")
71
- h3_btn = gr.Button("h3")
72
- all_btn = gr.Button("h1,h2,h3")
73
-
74
- scrape_btn = gr.Button("Scrape Blog")
75
-
 
76
  with gr.Column():
77
- with gr.Group(css_class="glass-card output-box"):
78
- output = gr.Textbox(label="Scraped Titles", interactive=False)
79
- copy_btn = gr.Button("Copy to Clipboard")
 
80
 
81
- # Tag button clicks
82
- h1_btn.click(lambda: "h1", inputs=None, outputs=tag_input)
83
- h2_btn.click(lambda: "h2", inputs=None, outputs=tag_input)
84
- h3_btn.click(lambda: "h3", inputs=None, outputs=tag_input)
85
- all_btn.click(lambda: "h1,h2,h3", inputs=None, outputs=tag_input)
86
 
87
- # Scrape button click
88
  scrape_btn.click(scrape, inputs=[url_input, tag_input], outputs=output)
89
 
90
- # Copy button (Gradio native copy support)
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()