Spaces:
Sleeping
Sleeping
Commit
Β·
5ecd59e
1
Parent(s):
a5f3e3d
fix
Browse files
app.py
CHANGED
|
@@ -2,65 +2,36 @@
|
|
| 2 |
|
| 3 |
import gradio as gr
|
| 4 |
import pandas as pd
|
| 5 |
-
import
|
| 6 |
from combined_email_finder import get_combined_emails
|
| 7 |
|
| 8 |
-
def
|
| 9 |
-
"""Yields progress messages during extraction and returns email list + downloadable CSV."""
|
| 10 |
-
yield "π‘ Step 1: Starting email extraction..."
|
| 11 |
-
|
| 12 |
-
time.sleep(0.5)
|
| 13 |
-
yield "π Step 2: Crawling the homepage and common subpages..."
|
| 14 |
-
|
| 15 |
-
time.sleep(0.5)
|
| 16 |
-
yield "π΅ Step 3: Searching engines like Google and Bing..."
|
| 17 |
-
|
| 18 |
-
time.sleep(0.5)
|
| 19 |
emails = get_combined_emails(domain)
|
| 20 |
-
|
| 21 |
if emails:
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
yield "β οΈ No valid emails found for this domain."
|
| 25 |
|
| 26 |
-
def
|
| 27 |
-
"""Returns CSV file for download based on extracted emails."""
|
| 28 |
emails = get_combined_emails(domain)
|
| 29 |
if not emails:
|
| 30 |
return None
|
| 31 |
df = pd.DataFrame({"Email": emails})
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
# Event: When 'Extract Emails' is clicked
|
| 53 |
-
submit_button.click(
|
| 54 |
-
extract_emails_with_feedback,
|
| 55 |
-
inputs=domain_input,
|
| 56 |
-
outputs=feedback_output
|
| 57 |
-
)
|
| 58 |
-
|
| 59 |
-
# Event: When 'Download CSV' is clicked
|
| 60 |
-
csv_button.click(
|
| 61 |
-
get_results_csv,
|
| 62 |
-
inputs=domain_input,
|
| 63 |
-
outputs=download_output
|
| 64 |
-
)
|
| 65 |
-
|
| 66 |
-
demo.launch(share=True)
|
|
|
|
| 2 |
|
| 3 |
import gradio as gr
|
| 4 |
import pandas as pd
|
| 5 |
+
import tempfile
|
| 6 |
from combined_email_finder import get_combined_emails
|
| 7 |
|
| 8 |
+
def extract_emails(domain):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
emails = get_combined_emails(domain)
|
|
|
|
| 10 |
if emails:
|
| 11 |
+
return "\n".join(emails)
|
| 12 |
+
return "β οΈ No valid emails found."
|
|
|
|
| 13 |
|
| 14 |
+
def export_csv(domain):
|
|
|
|
| 15 |
emails = get_combined_emails(domain)
|
| 16 |
if not emails:
|
| 17 |
return None
|
| 18 |
df = pd.DataFrame({"Email": emails})
|
| 19 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".csv", mode='w', encoding='utf-8') as tmp:
|
| 20 |
+
df.to_csv(tmp.name, index=False)
|
| 21 |
+
return tmp.name
|
| 22 |
+
|
| 23 |
+
iface = gr.Interface(
|
| 24 |
+
fn=extract_emails,
|
| 25 |
+
inputs=gr.Textbox(label="π Enter Domain (e.g. example.com)", placeholder="example.com"),
|
| 26 |
+
outputs=[
|
| 27 |
+
gr.Textbox(label="π§ Extracted Emails", lines=10),
|
| 28 |
+
gr.File(label="π₯ Download CSV")
|
| 29 |
+
],
|
| 30 |
+
title="AI-Powered EmailFinder",
|
| 31 |
+
description="Finds emails using webpage crawling and search engines via EmailFinder."
|
| 32 |
+
)
|
| 33 |
+
|
| 34 |
+
# Add a second function call for the CSV generator
|
| 35 |
+
iface.add_component("π₯ Download Emails as CSV", export_csv)
|
| 36 |
+
|
| 37 |
+
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|