From d972ff9e7fa4c4822352d66765e5161a9490d728 Mon Sep 17 00:00:00 2001 From: DiegoCaraballo Date: Mon, 12 Feb 2018 12:16:07 -0300 Subject: [PATCH] Agrego borrar por correo --- EmailExtractor.py | 53 +++++++++++++++++++++++++++++++++++++++++++--- Emails.db | Bin 73728 -> 73728 bytes 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/EmailExtractor.py b/EmailExtractor.py index c935efe..ac31dad 100644 --- a/EmailExtractor.py +++ b/EmailExtractor.py @@ -98,10 +98,13 @@ def menu(): op = input("Enter option: ") if(op == "1"): - pass + print("Example URL: http://www.pythondiario.com") + url = str(input("Insert URL: ")) + deleteUrl("Emails.db", url.strip()) elif(op == "2"): - pass + phrase = str(input("Insert Phrase: ")) + deletePhrase("Emails.db", phrase.strip()) elif(op == "3"): deleteAll("Emails.db") @@ -187,6 +190,49 @@ def crearTabla(db_file, delete = False): finally: conn.close() +# Borra todos los correos de una URL especĂ­fica +def deleteUrl(db_file, url): + try: + conn = sqlite3.connect(db_file) + c = conn.cursor() + sql = 'SELECT COUNT(*) FROM emails WHERE url = ' + '"' + url + '"' + result = c.execute(sql).fetchone() + + if(result[0] == 0): + print("There are no emails to erase") + input("Press enter to continue") + menu() + + else: + option = str(input("Are you sure you want to delete " + str(result[0]) + " emails? Y/N :")) + + if(option == "Y" or option == "y"): + c.execute("DELETE FROM emails WHERE url = " + '"' + url + '"') + conn.commit() + + print("Emails deleted") + input("Press enter to continue") + menu() + + elif(option == "N" or option == "n"): + print("Canceled operation, return to the menu ...") + time.sleep(2) + menu() + + else: + print("Select a correct option") + time.sleep(2) + deleteUrl(db_file, url) + + except Error as e: + print(e) + input("Press enter to continue") + menu() + +# Borra todos los correos de una Frase especĂ­fica +def deletePhrase(db_file, phrase): + pass + # Borra todos los correos def deleteAll(db_file): try: @@ -200,6 +246,7 @@ def deleteAll(db_file): input("Press enter to continue") menu() + else: option = str(input("Are you sure you want to delete " + str(result[0]) + " emails? Y/N :")) @@ -481,4 +528,4 @@ def Main(): crearTabla("Emails.db", False) menu() -Main() \ No newline at end of file +Main() diff --git a/Emails.db b/Emails.db index 466bdf52d9eeaaf2c93ce7e1979fc04df7a7f4dc..577e010affecafec7f4d31781956da812474a96b 100644 GIT binary patch delta 184 zcmZoTz|wGlWr8##=R_H2K~4tUzeT+KwhT;suNnAW^E+-9RH)|L{F+aaQG=aNgn@q> ze<8mn-+jJ$e35)2+`-u3#zJ-O$-&Z2EDQ`x^^<2x+khDMlW$5}GXoiu#bqpk0*pr{ zhsfB07)_I>$=HJ!KqX)ihQE`gWvzfB4ErZX%G!b$b(3ewT7ww&%{OJY-;`xkX958F CXDc88 delta 184 zcmZoTz|wGlWr8##$3z)tK@J8zi4(m1whT;suNnAW^E+-9RH)|L{F+aaQA3D3n1O#A ze<8mn-+jJ$e35)2yjOXr@rLq>^IYYb#1p_H!hMx{DtGY4LUr!R!O~7Fc7m)7lV?iX zu-FO!88@Y^nXUL)CyUEivN-So1wv%(SR8qQjA=6VEDk&%B|s4yZXiQi){4cR3&@C+ cwPms81TtpHTC>=4urf5?l-+()mQkGv0A2no1^@s6