獲取gmail新郵件---python版


#! /usr/bin/python
# -*- coding: utf-8 -*-
#author [email protected]

import httplib2
from xml.dom.minidom import parseString

#https://user:[email protected]/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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章