我想通过电子邮件地址从GMAIL和GROUP和SORT中提取所有电子邮件地址。结果是我联系最多的电子邮件地址的排序列表。
经过一些谷歌搜索
问题:如何通过电子邮件地址从GMAIL和GROUP和SORT中提取所有电子邮件地址?
向IMAP的出口是否有效(并从那里开始计算)?还是有更聪明的方式
非常感谢
答案 0 :(得分:0)
您有两个选择
使用Python中的Gmail API的示例代码
# Retrieve a page of threads
threads = gmail_service.users().threads().list(userId='me',fields='threads(id)').execute()
# Print ID for each thread
pp = pprint.PrettyPrinter(depth=5)
if threads['threads']:
for thread in threads['threads']:
print 'Thread ID: %s has messages from senders:' % (thread['id'])
t = gmail_service.users().threads().get(userId='me',id=thread['id'],fields='messages/payload/headers').execute()
for msg in t['messages']:
for header_from in [v for v in msg['payload']['headers'] if v['name'] == 'From']:
# There should be only one, but sometimes From is missing
from_field_val = header_from['value']
print from_field_val
# TODO Extract email address and increment count