Skip to content

Instantly share code, notes, and snippets.

@jongyeol
Created August 30, 2012 15:36
Show Gist options
  • Save jongyeol/3531134 to your computer and use it in GitHub Desktop.
Save jongyeol/3531134 to your computer and use it in GitHub Desktop.
숭실대학교 학식 문자 메시지 프로그램 (2008)
#!/usr/bin/python
# -*- coding: utf-8 -*-
# food2sms.py
# 숭실대학교 학식 문자 메시지 프로그램
# version: 2008.05.01.b
# coded by jong10
# need: http://twill.idyll.org/
# need: http://www.crummy.com/software/BeautifulSoup/
import sys
import re
import time
import urllib2
import codecs
from twill.commands import *
from BeautifulSoup import BeautifulSoup
print '-=+=-=+=< food2sms.py >=+=-=+=-'
if len(sys.argv) <= 2:
print 'Usage: python food2sms.py -(f|F) ["id;pass;phonenum"]...'
# -f : free mode
# -F : non-free mode
exit(1)
if sys.argv[1] == '-f':
url = 'http://skysms.co.kr/send_event/'
index = 9
elif sys.argv[1] == '-F':
url = 'http://skysms.co.kr/send_s/'
index = 14
else:
print "option is '-f' or '-F' only!"
exit(2)
####################################################
html = urllib2.urlopen('http://www.soongguri.com/inc.php?inc=weekly/weekly3').read()
html = html.decode('euc-kr', 'ignore').encode('utf-8')
soup = BeautifulSoup(html)
list = soup.fetch('td', {'height':'90%', 'class':'d', 'width':'100%', 'valign':'top'})
now = time.localtime()
p = re.compile('<.*?>')
lunch1 = p.sub('', str(list[ 6 + now.tm_wday]))
lunch2 = p.sub('', str(list[12 + now.tm_wday]))
dinner = p.sub('', str(list[24 + now.tm_wday]))
foods = []
foods.append("[점심A]\n" + lunch1)
foods.append("[점심B]\n" + lunch2)
foods.append("[저녁]\n" + dinner)
#for food in foods:
# print food
###################################################
args = sys.argv[2:]
for arg in args:
arg = arg.split(';')
userid = arg[0]
passwd = arg[1]
phone = arg[2]
go(url)
formvalue('login_form', 'userid', userid)
formvalue('login_form', 'passwd', passwd)
submit()
for food in foods:
go(url)
formvalue('msg_form', str(index), phone)
formvalue('msg_form', 'body', food.decode('utf-8').encode('euc-kr'))
submit()
@jongyeol
Copy link
Author

지금은 동작하지 않음.. 블로그 복구하면서 링크가 깨져서 백업함.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment