sheikhcoders commited on
Commit
cf6087a
Β·
verified Β·
1 Parent(s): b5f49b8

Gradio 4.21.0 app with compatible dependencies

Browse files
Files changed (1) hide show
  1. app.py +62 -59
app.py CHANGED
@@ -1,6 +1,6 @@
1
  #!/usr/bin/env python3
2
  """
3
- Browser Automation Tool for HuggingFace Spaces - Gradio 3 Compatible
4
  """
5
 
6
  import gradio as gr
@@ -103,66 +103,69 @@ def batch_navigate(urls, headless=True):
103
 
104
  return results
105
 
106
- # Gradio 3 Interface
107
- with gr.Blocks(title="Browser Automation Tool") as demo:
108
- gr.Markdown("# 🌐 Browser Automation Tool - Gradio 3 Compatible")
109
-
110
- with gr.Tab("Single URL"):
111
- with gr.Row():
112
- with gr.Column():
113
- url_input = gr.Textbox(label="URL to visit", placeholder="https://example.com")
114
- headless = gr.Checkbox(label="Headless mode", value=True)
115
- window_size = gr.Textbox(label="Window size", value="1920,1080")
116
-
117
- with gr.Column():
118
- navigate_btn = gr.Button("Navigate & Screenshot", variant="primary")
119
- extract_btn = gr.Button("Extract Content")
120
 
121
- screenshot_output = gr.Image(label="Screenshot")
122
- content_output = gr.Textbox(label="Content", lines=10)
123
-
124
- with gr.Tab("Batch Processing"):
125
- with gr.Row():
126
- with gr.Column():
127
- urls_input = gr.Textbox(
128
- label="URLs (one per line)",
129
- placeholder="https://example.com\nhttps://google.com",
130
- lines=5
131
- )
132
- batch_headless = gr.Checkbox(label="Headless mode", value=True)
133
- batch_btn = gr.Button("Process URLs", variant="primary")
134
 
135
- with gr.Column():
136
- batch_results = gr.JSON(label="Results")
137
-
138
- # Button handlers
139
- navigate_btn.click(
140
- fn=navigate_and_screenshot,
141
- inputs=[url_input, headless, window_size],
142
- outputs=[screenshot_output]
143
- )
144
-
145
- extract_btn.click(
146
- fn=extract_text_content,
147
- inputs=[url_input, headless],
148
- outputs=[content_output]
149
- )
150
-
151
- batch_btn.click(
152
- fn=batch_navigate,
153
- inputs=[urls_input, batch_headless],
154
- outputs=[batch_results]
155
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
 
157
- gr.Markdown("""
158
- ## Features
159
- - 🌐 **Web Browser Control**: Navigate websites programmatically
160
- - πŸ“Έ **Screenshot Capture**: Take screenshots of any webpage
161
- - πŸ” **Content Extraction**: Extract text content from HTML
162
- - ⚑ **Batch Processing**: Process multiple URLs at once
163
- - πŸ”§ **Configurable Options**: Headless mode, window sizes
164
- - βœ… **Gradio 3 Compatible**: No OAuth dependency issues
165
- """)
166
 
167
  if __name__ == "__main__":
168
- demo.launch(server_name="0.0.0.0", server_port=7860, share=False)
 
 
1
  #!/usr/bin/env python3
2
  """
3
+ Simple Browser Automation Tool for HuggingFace Spaces
4
  """
5
 
6
  import gradio as gr
 
103
 
104
  return results
105
 
106
+ # Gradio Interface
107
+ def main():
108
+ with gr.Blocks(title="Browser Automation Tool") as demo:
109
+ gr.Markdown("# 🌐 Browser Automation Tool - Build Fixed")
 
 
 
 
 
 
 
 
 
 
110
 
111
+ with gr.Tab("Single URL"):
112
+ with gr.Row():
113
+ with gr.Column():
114
+ url_input = gr.Textbox(label="URL to visit", placeholder="https://example.com")
115
+ headless = gr.Checkbox(label="Headless mode", value=True)
116
+ window_size = gr.Textbox(label="Window size", value="1920,1080")
117
+
118
+ with gr.Column():
119
+ navigate_btn = gr.Button("Navigate & Screenshot", variant="primary")
120
+ extract_btn = gr.Button("Extract Content")
 
 
 
121
 
122
+ screenshot_output = gr.Image(label="Screenshot")
123
+ content_output = gr.Textbox(label="Content", lines=10)
124
+
125
+ with gr.Tab("Batch Processing"):
126
+ with gr.Row():
127
+ with gr.Column():
128
+ urls_input = gr.Textbox(
129
+ label="URLs (one per line)",
130
+ placeholder="https://example.com\nhttps://google.com",
131
+ lines=5
132
+ )
133
+ batch_headless = gr.Checkbox(label="Headless mode", value=True)
134
+ batch_btn = gr.Button("Process URLs", variant="primary")
135
+
136
+ with gr.Column():
137
+ batch_results = gr.JSON(label="Results")
138
+
139
+ # Button handlers
140
+ navigate_btn.click(
141
+ fn=navigate_and_screenshot,
142
+ inputs=[url_input, headless, window_size],
143
+ outputs=[screenshot_output]
144
+ )
145
+
146
+ extract_btn.click(
147
+ fn=extract_text_content,
148
+ inputs=[url_input, headless],
149
+ outputs=[content_output]
150
+ )
151
+
152
+ batch_btn.click(
153
+ fn=batch_navigate,
154
+ inputs=[urls_input, batch_headless],
155
+ outputs=[batch_results]
156
+ )
157
+
158
+ gr.Markdown("""
159
+ ## Features
160
+ - 🌐 **Web Browser Control**: Navigate websites programmatically
161
+ - πŸ“Έ **Screenshot Capture**: Take screenshots of any webpage
162
+ - πŸ” **Content Extraction**: Extract text content from HTML
163
+ - ⚑ **Batch Processing**: Process multiple URLs at once
164
+ - πŸ”§ **Configurable Options**: Headless mode, window sizes
165
+ """)
166
 
167
+ return demo
 
 
 
 
 
 
 
 
168
 
169
  if __name__ == "__main__":
170
+ demo = main()
171
+ demo.launch(server_name="0.0.0.0", server_port=7860)