Skip to content

Instantly share code, notes, and snippets.

@dongyuwei
Created July 9, 2010 09:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dongyuwei/469271 to your computer and use it in GitHub Desktop.
Save dongyuwei/469271 to your computer and use it in GitHub Desktop.
read gmail feeds,write in python
#! /usr/bin/python
# -*- coding: utf-8 -*-
#author newdongyuwei@gmail.com
import httplib2
from xml.dom.minidom import parseString
#https://user:password@mail.google.com/mail/feed/atom
gmail_feed_url = "https://mail.google.com/mail/feed/atom"
user="newdongyuwei"
password = "xxxxxx"
http = httplib2.Http()
http.add_credentials(user, password)#basic auth
resp, content = http.request(gmail_feed_url , "GET", body={}, headers={} )
print resp,content
dom = parseString(content)
feed_list = dom.getElementsByTagName('entry')
result = []
for feed in feed_list:
result.append(";".join([feed.getElementsByTagName("title")[0].firstChild.nodeValue.strip(),feed.getElementsByTagName("summary")[0].firstChild.nodeValue.strip(),feed.getElementsByTagName("name")[0].firstChild.nodeValue.strip()]))
print result
@dickguertin
Copy link

python can't find 'httplib2 on Sierra. How do I get it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment