Spaces:
Sleeping
Sleeping
Commit Β·
86d57b9
1
Parent(s): 0159c5b
Added features
Browse files- app.py +54 -11
- combined_email_finder.py +0 -18
app.py
CHANGED
|
@@ -2,20 +2,63 @@
|
|
| 2 |
|
| 3 |
import gradio as gr
|
| 4 |
import pandas as pd
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
def get_results_csv(domain):
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
| 9 |
df = pd.DataFrame({"Email": emails})
|
| 10 |
-
csv_path = "
|
| 11 |
df.to_csv(csv_path, index=False)
|
| 12 |
return csv_path
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
import gradio as gr
|
| 4 |
import pandas as pd
|
| 5 |
+
import time
|
| 6 |
+
from combined_email_finder import get_combined_emails
|
| 7 |
+
|
| 8 |
+
def extract_emails_with_feedback(domain):
|
| 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 |
+
yield "π’ Step 4: Emails found!\n" + "\n".join(emails)
|
| 23 |
+
else:
|
| 24 |
+
yield "β οΈ No valid emails found for this domain."
|
| 25 |
|
| 26 |
def get_results_csv(domain):
|
| 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 |
+
csv_path = "extracted_emails.csv"
|
| 33 |
df.to_csv(csv_path, index=False)
|
| 34 |
return csv_path
|
| 35 |
|
| 36 |
+
# --- GRADIO UI ---
|
| 37 |
+
|
| 38 |
+
with gr.Blocks(title="AI-Powered Email Extractor", theme=gr.themes.Default()) as demo:
|
| 39 |
+
gr.Markdown("# π§ AI-Powered EmailFinder")
|
| 40 |
+
gr.Markdown("This adaptive interface finds emails from a domain using both live scraping and search engines.")
|
| 41 |
+
|
| 42 |
+
with gr.Row():
|
| 43 |
+
domain_input = gr.Textbox(label="π Enter a Domain (e.g. example.com)", elem_id="domain_input", info="Required for email extraction")
|
| 44 |
+
|
| 45 |
+
with gr.Row():
|
| 46 |
+
submit_button = gr.Button("π Extract Emails")
|
| 47 |
+
csv_button = gr.Button("π₯ Download Emails as CSV")
|
| 48 |
+
|
| 49 |
+
feedback_output = gr.Textbox(label="π Progress & Results", lines=10)
|
| 50 |
+
download_output = gr.File(label="Download CSV File", file_types=[".csv"])
|
| 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 |
+
)
|
combined_email_finder.py
CHANGED
|
@@ -47,24 +47,6 @@ def get_combined_emails(domain):
|
|
| 47 |
valid_emails = filter_emails(all_emails)
|
| 48 |
return valid_emails or ["No emails found."]
|
| 49 |
|
| 50 |
-
# DYNAMIC FEEDBACK
|
| 51 |
-
|
| 52 |
-
def get_emails_with_feedback(domain):
|
| 53 |
-
import time
|
| 54 |
-
|
| 55 |
-
yield "Starting email search..."
|
| 56 |
-
time.sleep(0.5)
|
| 57 |
-
yield "Scraping hompage and key pages..."
|
| 58 |
-
time.sleep(0.5)
|
| 59 |
-
yield "Quering search engines..."
|
| 60 |
-
time.sleep(0.5)
|
| 61 |
-
|
| 62 |
-
emails = get_combined_emails(domain)
|
| 63 |
-
if emails and isinstance(emails, list):
|
| 64 |
-
yield "Emails found:\n" + "\n".join(emails)
|
| 65 |
-
else:
|
| 66 |
-
yield "No valid emails found."
|
| 67 |
-
|
| 68 |
if __name__ == "__main__":
|
| 69 |
emails = get_combined_emails("gunvorgroup.com")
|
| 70 |
print("Found emails:")
|
|
|
|
| 47 |
valid_emails = filter_emails(all_emails)
|
| 48 |
return valid_emails or ["No emails found."]
|
| 49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
if __name__ == "__main__":
|
| 51 |
emails = get_combined_emails("gunvorgroup.com")
|
| 52 |
print("Found emails:")
|