Created
April 9, 2013 09:12
-
-
Save gunyarakun/5344255 to your computer and use it in GitHub Desktop.
京都の東横インの予約をひたすらさがすスクリプト、発掘したので放置
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# 巨乳 | |
import urllib | |
import urllib2 | |
import codecs | |
import re | |
import smtplib | |
from email.MIMEText import MIMEText | |
from email.Utils import formatdate | |
import sys | |
sys.stdin = codecs.getreader('utf-8')(sys.stdin) | |
sys.stdout = codecs.getwriter('utf-8')(sys.stdout) | |
def create_message(from_addr, to_addr, subject, body): | |
msg = MIMEText(body) | |
msg['Subject'] = subject | |
msg['From'] = from_addr | |
msg['To'] = to_addr | |
msg['Date'] = formatdate() | |
return msg | |
def send_via_gmail(from_addr, to_addr, msg): | |
s = smtplib.SMTP('smtp.gmail.com', 587) | |
s.ehlo() | |
s.starttls() | |
s.ehlo() | |
s.login(gmail_id, gmail_password) | |
s.sendmail(from_addr, [to_addr], msg.as_string()) | |
s.close() | |
if __name__ == '__main__': | |
f = codecs.getreader('utf-8')(urllib.urlopen('https://yoyaku.4and5.com/reserve/html/rvpc_srchHtl.html?htlDtl=true&cntry=JPN&chcknYearAndMnth=201211&chcknDayOfMnth=17&ldgngNum=1&roomNum=1&roomClssId=&prfctr=26&htlName=&mncplty=&language=ja&dtlShowHtlUid=0&htlRegionaOneUid=0&htlRegionaTowUid=0&htlRegionaThreeUid=0&id=&ldgngPpl=1&dispFull=on#')) | |
html = f.read() | |
r = re.compile(ur'空室あり') | |
m = r.findall(html) | |
if m: | |
from_addr = '[email protected]' | |
to_addr = '[email protected]' | |
msg = create_message(from_addr, to_addr, u'東横イン予約チェック', '予約あったよー!') | |
send_via_gmail(from_addr, to_addr, msg) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment