Ok, dopo un po' di tentativi sono riuscito a fare un ulteriore passo in avanti.
Al momento mi trovo con un file.txt contenente un bel po' di testo che a me non serve.
Cio' che mi servirebbe sarebbe estrarre i link come evidenziato sotto:
Codice:
Tested just uploaded a video
Halftime Drones - This is Only a Test 386 - 2/9/17
http://www.youtube.com/watch?v=zDb_rotMvho&feature=em-uploademail
You can unsubscribe from notifications for this user by visiting the
subscription center:
http://www.youtube.com/subscription_manager
Tested just uploaded a video
This is only an example
http://www.youtube.com/watch?v=hdte5qlc9rb&feature=em-uploademail
You can unsubscribe from notifications for this user by visiting the
subscription center:
http://www.youtube.com/subscription_manager
In modo da ottenere un file di testo contenente solo:
Codice:
http://www.youtube.com/watch?v=zDb_rotMvho
http://www.youtube.com/watch?v=hdte5qlc9rb
Che ne dite, si puo' fare?
Ho dimenticato lo script aggiornato

:
Codice:
#!/usr/bin/env python
import datetime
import email
import imaplib
import mailbox
print '----------------------------'
print 'Login...'
mail = imaplib.IMAP4_SSL('imap.gmail.com')
try:
mail.login('youremail', 'yourpassword')
print "Success."
except imaplib.IMAP4.error:
print "LOGIN FAILED!!! "
# ... exit or deal with failure...
mail.list() # Lists all labels in GMail
mail.select('YTsubs') # Select YTsubs folder
print '----------------------------'
n=0
(retcode, messages) = mail.search(None, '(UNSEEN)')
if retcode == 'OK':
for num in messages[0].split() :
#print 'Processing...'
n=n+1
typ, data = mail.fetch(num,'(RFC822)')
print "Processing %s." % n
for response_part in data:
if isinstance(response_part, tuple):
original = email.message_from_string(response_part[1])
#print original
print original['From']
print original['Subject']
myfile = open("Extractedemail.txt", 'a')
#myfile.write("original\n")
myfile.write("---------- Indentation line ---------- \n %s \n" % original)
myfile.close()
typ, data = mail.store(num,'+FLAGS','\\Seen')
print '----------------------------'
print "Total processed: %s." % n
print '----------------------------'