Posted by harski on Wed 31st Aug 22:46 (modification of post by view diff)
download | new post
- #!/usr/bin/env python3
- """
- Version 110412
- Improved error-handling and modified to use python3
- Written by Tuomo Hartikainen <hartitu@gmail.com>
- Feel free to distribute or modify in any way you like.
- """
- import os
- #Enter your username and password below enclosed with double quotes
- # eg. username="username" and password="password"
- username=""
- password=""
- def fetchInfo(username, password):
- """ Takes username and password as parameter. Checks
- the site for mail and returns the count of new
- messages. Returns -1 on error.
- """
- mail = 0
- wget = "wget -q -O - https://"+username+":"+password+"@mail.google.com/mail/feed/atom --no-check-certificate"
- #Do the dirty work
- temp = os.popen(wget)
- msg = temp.read()
- index = msg.find("<fullcount>")
- index2 = msg.find("</fullcount>")
- try:
- mail = int(msg[index+11:index2])
- except:
- mail = -1
- return mail
- messages = fetchInfo(username, password)
- if messages != -1:
- print(str(messages), "messages")
- else:
- #An error happened. Deal with it
- print("Error fetching mail")
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.