#! /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
获取gmail新邮件---python版
最新推荐文章于 2025-03-19 16:00:59 发布
本文提供了一个使用 Python 通过 Gmail API 获取未读邮件信息的示例代码。该脚本利用 httplib2 发起 HTTP 请求,并解析返回的 Atom 喂送格式的内容。
1554

被折叠的 条评论
为什么被折叠?



