File size: 1,202 Bytes
3058953
7eef865
 
3058953
7eef865
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41

import gradio as gr
from smolagents import load_tool

web_extractor = load_tool("MHamdan/web-content-extractor", trust_remote_code=True)

def create_interface():
    with gr.Blocks(title="Web Content Extractor") as iface:
        gr.Markdown("# Web Content Extractor")
        gr.Markdown("Extract and analyze content from any webpage.")
        
        with gr.Row():
            with gr.Column():
                url_input = gr.Textbox(
                    label="Webpage URL",
                    placeholder="https://example.com"
                )
                content_type = gr.Dropdown(
                    choices=["all", "text", "links", "headers"],
                    label="Content Type",
                    value="all"
                )
                submit_btn = gr.Button("Extract Content")
                
            with gr.Column():
                output = gr.Textbox(
                    label="Extracted Content",
                    lines=10
                )
        
        submit_btn.click(
            fn=web_extractor,
            inputs=[url_input, content_type],
            outputs=output
        )
    
    return iface

demo = create_interface()
demo.launch()