-
Notifications
You must be signed in to change notification settings - Fork 8
/
main.py
57 lines (48 loc) · 1.53 KB
/
main.py
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"""
* Email Scraper
* Author: Sanjay Sunil
* License: MIT
"""
import os
import webbrowser
from src.email_scraper import EmailScraper
OPTIONS = ["Scrape 1 Email", "Scrape Multiple Emails",
"View Project Information", "Exit"]
PROJECT_URL = "https://github.com/sanjaysunil/email-scraper"
os.system('clear')
while True:
os.system('clear')
print("Email Scraper\n")
[print(i+1, OPTIONS[i]) for i in range(len(OPTIONS))]
print('\n')
while True:
try:
option = int(input("Choose an option: "))
break
except ValueError:
print('Please type an option number.\n')
if option == 1:
file_to_write = input('Enter filename to write to: ')
scraper = EmailScraper(file_path=file_to_write)
print(scraper.start(1))
back_to_menu = input(
f'\n\nPress enter to go back to menu. ')
elif option == 2:
while True:
try:
emails = int(input("Emails to scrape: "))
break
except ValueError:
print('Please enter a valid number of emails.')
file_to_write = input('Enter filename to write to: ')
scraper = EmailScraper(file_path=file_to_write)
print(scraper.start(emails))
back_to_menu = input(
f'\n\nPress enter to go back to menu. ')
elif option == 3:
webbrowser.open(PROJECT_URL)
elif option == 4:
exit("Thank you for using email-scraper.")
else:
try_again = input(
'Invalid option, please enter to try again. ')