def get(self): word = self.get_argument('word', '').split(" ") start_time = time.time() result = get_msg(keyword=word) end_time = time.time() result = gen_news_str(result["news"])# + gen_weibo_str(result["weibo"]) logger.debug("found result: %s" % result) logger.debug("this search took %s seconds" % (end_time-start_time)) self.write('''<html><body>'''+result.replace("\n", "<br>")+'''</body></html>''')
def daemon_main(interval=300): """ 1. 获取所有需要翻译的keywords, 分级别:5分钟,2分钟等,默认五分钟 ; 2. 搜寻百度、微博等最新消息 ; 3. 验证待发送的email_list; 3. 根据keywords注册的email_list将最新消息内容发送给相应email用户; 4. 将内容存入mongo中的content数据库; """ words_emails = Keywords.get_search_words(interval) print "word_emails=", words_emails for word, emails in words_emails: # AccountSetting.update_search_time(emails, word, time.time()) latest_content = get_msg(word, word) print "content", latest_content send_msg(emails, word, word, latest_content)