File size: 1,248 Bytes
d2019da
0159c5b
5ecd59e
86d57b9
 
5ecd59e
86d57b9
99d880b
0159c5b
5ecd59e
86d57b9
 
 
0159c5b
5ecd59e
 
 
 
b5894f9
 
 
 
 
 
 
 
5ecd59e
b5894f9
 
 
 
 
 
 
 
 
 
 
 
 
5ecd59e
99d880b
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
42
import gradio as gr
import pandas as pd
import tempfile
from combined_email_finder import get_combined_emails

def extract_emails(domain):
    emails = get_combined_emails(domain)
    return "\n".join(emails) if emails else "⚠️ No valid emails found."

def export_csv(domain):
    emails = get_combined_emails(domain)
    if not emails:
        return None
    df = pd.DataFrame({"Email": emails})
    with tempfile.NamedTemporaryFile(delete=False, suffix=".csv", mode='w', encoding='utf-8') as tmp:
        df.to_csv(tmp.name, index=False)
        return tmp.name

# Create the two interfaces
email_interface = gr.Interface(
    fn=extract_emails,
    inputs=gr.Textbox(label="Enter Domain"),
    outputs=gr.Textbox(label="Extracted Emails", lines=10),
    title="📧 Email Extractor",
    description="Scrapes and extracts emails from a domain."
)

csv_interface = gr.Interface(
    fn=export_csv,
    inputs=gr.Textbox(label="Enter Domain"),
    outputs=gr.File(label="Download CSV"),
    title="📥 CSV Exporter",
    description="Download extracted emails as a CSV file."
)

# Combine into tabbed interface
demo = gr.TabbedInterface(
    [email_interface, csv_interface],
    tab_names=["Extract Emails", "Download CSV"]
)

demo.launch()