def print_teachersblog_msg(): global new_message_from_chengang global new_homework_from_chengang if new_message_from_chengang != 0: message = str(new_message_from_chengang) + "条来自陈刚的新消息" if new_homework_from_chengang != 0: message += ",其中有" + str(new_homework_from_chengang) + "个新作业\n" else: message += "\n" send_notify(message)
def get_new_movies_info(): global meicao_movie_base_url global meicao_movies_info_url global conn global cursor meicao_info_html = urllib2.urlopen(meicao_movies_info_url).read().decode( 'gb2312').encode('utf-8') regex = re.compile( u'<td width="87%" class="k2"><a href="(?P<url>.*)" class=.*>(?P<title>.*)</a></td>' .encode('utf-8')) for m in re.finditer(regex, meicao_info_html): title = m.group('title') url = meicao_movie_base_url + m.group('url') movie_html = urllib2.urlopen(url).read().decode('gb2312').encode( 'utf-8') movie_html = clear_html(movie_html) match_result = re.search( u'<P>电影名称:</P><P>(?P<name>.*)</P><P>时间:(?P<time>.*)</P><P>地点'. encode('utf-8'), movie_html) if match_result == None: time = '' try: cursor.execute("INSERT INTO meicao_movie VALUES(?, ?)", (title, "None")) except sqlite3.IntegrityError: return None else: message = title #print message send_email(email_to, "梅操电影消息", message, "plain") send_notify(message) else: name_str = match_result.group('name') name_str = name_str.replace('<P>', '') name_str = name_str.replace('</P>', ' ') time = match_result.group('time') try: cursor.execute("INSERT INTO meicao_movie VALUES(?, ?)", (title, time)) except sqlite3.IntegrityError: return None else: message = time + ': ' + name_str #print message send_email(email_to, "梅操电影 " + time, message, "plain") send_notify(message) conn.commit()
def get_new_movies_info(): global meicao_movie_base_url global meicao_movies_info_url global conn global cursor meicao_info_html = urllib2.urlopen(meicao_movies_info_url).read().decode('gb2312').encode('utf-8') regex = re.compile(u'<td width="87%" class="k2"><a href="(?P<url>.*)" class=.*>(?P<title>.*)</a></td>'.encode('utf-8')) for m in re.finditer(regex, meicao_info_html): title = m.group('title') url = meicao_movie_base_url + m.group('url') movie_html = urllib2.urlopen(url).read().decode('gb2312').encode('utf-8') movie_html = clear_html(movie_html) match_result = re.search(u'<P>电影名称:</P><P>(?P<name>.*)</P><P>时间:(?P<time>.*)</P><P>地点'.encode('utf-8'), movie_html) if match_result == None: time = '' try: cursor.execute("INSERT INTO meicao_movie VALUES(?, ?)", (title, "None")) except sqlite3.IntegrityError: return None else: message = title #print message send_email(email_to, "梅操电影消息", message, "plain") send_notify(message) else: name_str = match_result.group('name') name_str = name_str.replace('<P>', '') name_str = name_str.replace('</P>', ' ') time = match_result.group('time') try: cursor.execute("INSERT INTO meicao_movie VALUES(?, ?)", (title, time)) except sqlite3.IntegrityError: return None else: message = time + ': ' + name_str #print message send_email(email_to, "梅操电影 " + time, message, "plain") send_notify(message) conn.commit()
def print_iss_msg(): global new_message_from_iss_bachelor_info if new_message_from_iss_bachelor_info != 0: message = str(new_message_from_iss_bachelor_info) + "条来自国际软件学院的新消息\n" send_notify(message)