JayBene1 commited on
Commit
2637db1
·
verified ·
1 Parent(s): c175eac

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -47
app.py CHANGED
@@ -303,7 +303,7 @@ def parse_csv_file(file_content):
303
  except Exception as e:
304
  print(f"Error parsing CSV: {e}")
305
  return []
306
-
307
  def search_csv_websites(csv_file, max_results=10):
308
  """Search for contacts from websites listed in CSV file"""
309
  if csv_file is None:
@@ -314,7 +314,7 @@ def search_csv_websites(csv_file, max_results=10):
314
  websites = parse_csv_file(csv_file)
315
 
316
  if not websites:
317
- return "No websites found in CSV file. Please ensure your CSV has a column named 'website', 'url', or 'domain'. Check the console for debugging info about your CSV columns.", ""
318
 
319
  all_contacts = []
320
  processed_websites = []
@@ -372,50 +372,6 @@ def search_csv_websites(csv_file, max_results=10):
372
  except Exception as e:
373
  return f"Error processing CSV file: {str(e)}", ""
374
 
375
- def search_website_contacts(website_url, max_results=10):
376
- """Main function to search for contacts on a website"""
377
- if not website_url:
378
- return "Please enter a website URL", ""
379
-
380
- # Clean up URL
381
- if not website_url.startswith(('http://', 'https://')):
382
- website_url = 'https://' + website_url
383
-
384
- try:
385
- # Simulate finding contacts
386
- contacts = simulate_website_scraping(website_url)
387
-
388
- if not contacts:
389
- return f"No contacts found on {website_url}. \n\nThis website is not in our contact database. Try one of the sample websites listed below, or the website might not have publicly available contact information.", ""
390
-
391
- # Limit results
392
- contacts = contacts[:max_results]
393
-
394
- # Format results
395
- results_text = f"CONTACT INTELLIGENCE REPORT\n"
396
- results_text += f"Website: {website_url}\n"
397
- results_text += f"Contacts Found: {len(contacts)}\n"
398
- results_text += f"{'='*60}\n\n"
399
-
400
- for i, contact in enumerate(contacts, 1):
401
- results_text += f"CONTACT #{i}\n"
402
- results_text += f"First Name: {contact['first_name']}\n"
403
- results_text += f"Last Name: {contact['last_name']}\n"
404
- results_text += f"Position: {contact['job_title']}\n"
405
- results_text += f"Email: {contact['email']}\n"
406
- results_text += f"Phone: {contact['phone']}\n"
407
- results_text += f"Company: {contact['company']}\n\n"
408
-
409
- # Create a simple table format for the second output
410
- table_text = "First Name,Last Name,Job Title,Email,Phone,Company\n"
411
- for contact in contacts:
412
- table_text += f"{contact['first_name']},{contact['last_name']},{contact['job_title']},{contact['email']},{contact['phone']},{contact['company']}\n"
413
-
414
- return results_text, table_text
415
-
416
- except Exception as e:
417
- return f"Error searching website: {str(e)}", ""
418
-
419
  def get_all_available_websites():
420
  """Get list of all available websites from the database"""
421
  websites = list(set([contact['website'] for contact in CONTACTS_DB]))
@@ -615,7 +571,7 @@ with gr.Blocks(css=custom_css, title="Contact Discovery Platform", theme=gr.them
615
  gr.HTML("""
616
  <div style="background: #f8fafc; padding: 15px; border-radius: 8px; border-left: 4px solid #1e40af; margin: 10px 0;">
617
  <strong>CSV Format Requirements:</strong><br>
618
- Include a column named 'website', 'url', or 'domain'<br>
619
  • One website per row<br>
620
  • Example: techflowsolutions.com, greenleafconsult.com
621
  </div>
 
303
  except Exception as e:
304
  print(f"Error parsing CSV: {e}")
305
  return []
306
+
307
  def search_csv_websites(csv_file, max_results=10):
308
  """Search for contacts from websites listed in CSV file"""
309
  if csv_file is None:
 
314
  websites = parse_csv_file(csv_file)
315
 
316
  if not websites:
317
+ return "No websites found in CSV file. Please ensure your CSV has website URLs in column H. Check the console for debugging info about your CSV structure.", ""
318
 
319
  all_contacts = []
320
  processed_websites = []
 
372
  except Exception as e:
373
  return f"Error processing CSV file: {str(e)}", ""
374
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
375
  def get_all_available_websites():
376
  """Get list of all available websites from the database"""
377
  websites = list(set([contact['website'] for contact in CONTACTS_DB]))
 
571
  gr.HTML("""
572
  <div style="background: #f8fafc; padding: 15px; border-radius: 8px; border-left: 4px solid #1e40af; margin: 10px 0;">
573
  <strong>CSV Format Requirements:</strong><br>
574
+ Website URLs must be in column H<br>
575
  • One website per row<br>
576
  • Example: techflowsolutions.com, greenleafconsult.com
577
  </div>