Nexus7を購入してから次の2つの電子書籍のDailyDealにはよく目を通すようになった。
ApressのほうはGoogle Readerでうまく更新されなくてちょっと困ったので、毎朝Gmailに送るようにしてみた。
import requests import feedparser import smtplib from email.MIMEText import MIMEText from email.Header import Header from email.Utils import formatdate EMAIL = 'your_account@gmail.com' PASSWORD = 'your_password' def sendmail(subject, body): msg = MIMEText(body, 'plain', 'utf-8') msg['Subject'] = Header(subject, 'utf-8') msg['From'] = EMAIL msg['To'] = EMAIL msg['Date'] = formatdate() s = smtplib.SMTP('smtp.gmail.com', 587) s.ehlo() s.starttls() s.ehlo() s.login(EMAIL, PASSWORD) s.sendmail(EMAIL, EMAIL, msg.as_string()) s.close() if __name__ == '__main__': r = requests.get("http://www.apress.com/index.php/dailydeals/index/rss") if r.status_code == 200: d = feedparser.parse(r.content) e = d.entries[0] sendmail( u"[APRESS DailyDeal] {}".format(e.title), u"{}\n\n{}".format(e.summary, e.links[0].href) )
ちなみに本日のディールはProtect Your Wealth from the Ravages of Inflationという本で僕は想定読者ではなかった。
people who have reached a level of financial stability and whose income is greater than monthly expenses.