Last active
August 29, 2015 13:55
-
-
Save thesnapdragon/8721926 to your computer and use it in GitHub Desktop.
little Python script that writes out the count of unread gmails
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 | |
# -*- coding: utf-8 -*- | |
# Milán Unicsovics, u.milan at gmail dot com | |
# usage: ./gmailToConky.py | |
# writes out the count of unread gmails | |
import requests | |
from xml.dom.minidom import parseString | |
def main(): | |
try: | |
user = 'EMAILADDRESS' | |
password = 'PASSWORD' | |
response = requests.get('https://mail.google.com/mail/feed/atom'.format(user, password), auth=(user, password)) | |
xml = parseString(response.text.encode('utf-8')) | |
print(xml.getElementsByTagName('fullcount')[0].childNodes[0].nodeValue) | |
except requests.exceptions.Timeout: | |
print(0) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment