lolamontes69

Python / Check Your Gmail script

Jun 10th, 2013
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.74 KB | None | 0 0
  1. # -*- coding: utf-8 -*-  
  2. import feedparser  
  3. import urllib2  
  4.  
  5. auth_handler = urllib2.HTTPBasicAuthHandler()  
  6. auth_handler.add_password('New mail feed', 'https://mail.google.com/', 'USERNAME@DOMAIN', 'PASSWORD')  
  7. opener = urllib2.build_opener(auth_handler)  
  8. feed_file = opener.open('https://mail.google.com/mail/feed/atom/')  
  9. d = feedparser.parse(feed_file)  
  10. print 'Mail count:', d.feed.fullcount  
  11. for entry in d.entries:  
  12.     print '----------------------------------------------'  
  13.     print 'Author: ', entry.author  
  14.     print 'Subject:', entry.title  
  15.     print 'Summary:', entry.summary
  16.  
  17. """ Snarfed from:
  18.      http://pysnippet.blogspot.com/2009/10/diy-google-mail-notifier.html
  19.      Credit where credit is due :)
  20. """
Advertisement
Add Comment
Please, Sign In to add comment