Created
July 30, 2012 21:09
-
-
Save Paaskehare/3210264 to your computer and use it in GitHub Desktop.
Python3 Script for counting unread emails from gmail, useful for conky
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# encoding: utf-8 | |
from urllib.request import FancyURLopener | |
username = 'username' | |
password = 'superlongandhardpassword' | |
url = 'https://%s:%[email protected]/mail/feed/atom' % (username, password) | |
opener = FancyURLopener() | |
page = opener.open(url) | |
contents = page.read().decode('utf-8') | |
ifrom = contents.index('<fullcount>') + 11 | |
ito = contents.index('</fullcount>') | |
unread = contents[ifrom:ito] | |
print(unread) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment