Gradio 4.21.0 app with compatible dependencies
Browse files
app.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
"""
|
| 3 |
-
Browser Automation Tool for HuggingFace Spaces
|
| 4 |
"""
|
| 5 |
|
| 6 |
import gradio as gr
|
|
@@ -103,66 +103,69 @@ def batch_navigate(urls, headless=True):
|
|
| 103 |
|
| 104 |
return results
|
| 105 |
|
| 106 |
-
# Gradio
|
| 107 |
-
|
| 108 |
-
gr.
|
| 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 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
)
|
| 132 |
-
batch_headless = gr.Checkbox(label="Headless mode", value=True)
|
| 133 |
-
batch_btn = gr.Button("Process URLs", variant="primary")
|
| 134 |
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 156 |
|
| 157 |
-
|
| 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
|
|
|
|
|
|
| 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)
|