[Tutor] Python gmail script for conky
Polo Heysquierdo
brownboyrx at gmail.com
Sun Jan 20 00:27:46 CET 2013
I'm getting the following error on my script for conky.
"Traceback (most recent call last):
File "/home/troll/.gmail/gmail.py", line 1, in <module>
import urllib.request
ImportError: No module named request"
code below:
import urllib.request
from xml.etree import ElementTree as etree
# Enter your username and password below within quotes below, in place of
****.
# Set up authentication for gmail
auth_handler = urllib.request.HTTPBasicAuthHandler()
auth_handler.add_password(realm='New mail feed',
url='https://mail.google.com/',
user= 'username',
passwd= 'gmail')
opener = urllib.request.build_opener(auth_handler)
# ...and install it globally so it can be used with urlopen.
urllib.request.install_opener(opener)
gmail = 'https://mail.google.com/gmail/feed/atom'
NS = '{http://purl.org/atom/ns#}'
with urllib.request.urlopen('https://mail.google.com/gmail/feed/atom') as
source:
tree = etree.parse(source)
fullcount = tree.find(NS + 'fullcount').text
print(fullcount + ' new')
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130119/b858f973/attachment.html>
More information about the Tutor
mailing list