Wassr(ry
ã¨ããããã³ã¼ãã®ã¿
#!/usr/bin/env python # -*- coding: utf-8 -*- gmailuser='[email protected]' gmailpasswd='kogaidan' wassruser = 'dankogai' wassrpasswd = 'kogaidan' host = 'imap.gmail.com' from imaplib import IMAP4_SSL from mailbox import mbox import re,urllib print 'start' gmail = IMAP4_SSL(host) gmail.login(gmailuser,gmailpasswd) gmail.select('[Gmail]/All Mail') mails = gmail.search(None, 'FROM', '"[email protected]"', 'UNSEEN') for num in mails[1][0].split(): typ, data = gmail.fetch(num,'(BODY[TEXT])') body = data[0][1] result = re.findall(r'http://wassr\.(?:jp|com)/user/(\w+)/',body) if result: name = result[0] if name and name != wassruser: print urllib.urlopen('http://%s:%[email protected]/friendships/create/%s.json' % (wassruser,wassrpasswd,name),'').read() gmail.store(num, 'FLAGS.SILENT', '(\SEEN)') print 'add ' + name gmail.close() print 'end'