Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python2.7
- # Cuenta correos en spam
- #
- # Debe instalar 'pygmail':
- # pip install pygmail
- import gmail
- import logging
- # logger
- logger = logging.getLogger('bob')
- hdlr = logging.FileHandler('bob.log')
- formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
- hdlr.setFormatter(formatter)
- logger.addHandler(hdlr)
- logger.setLevel(logging.INFO)
- def main(username='spam', password='nospam'):
- '''
- Me autentico a Gmail para contar correos en spam y busco solo
- no-leidos
- '''
- g = gmail.login(username, password)
- emails = g.mailbox('[Gmail]/Spam').mail(unread=True)
- print("Correos en spam {}".format(len(emails)))
- logger.info('Correos en spam %s' % (len(emails)))
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement