def cycle(): mylist = get_hitsz() post_list = [] maxid = get_maxid() tmax = maxid for item in mylist: item_id = get_strid(item["href"]) if(item_id > maxid): post_list.append(item) if(item_id > tmax): tmax = item_id ylib.log_pf("new news list length : " + str(len(post_list)) ); if len(post_list) > 0: ylib.log_pf("新增加新闻") for item in post_list: ylib.log_pf(item["text"].replace(".","") + " " + item["href"]) mystr = "<h3> ^V^ </h3>" for item in post_list: mystr += "<a href ='" + item["href"] + "'>"+ "<p>" + item["text"] + "</p>" + "</a>" if tmax != maxid: write_maxid(tmax) import my_email as me import user subject = "Fresh news in : " + str(ylib.get_now_time()) for item in user.users: import time time.sleep(5) if me.send_mail(item.email,subject,mystr) == 1: ylib.log_pf(item.name + " 发送成功") else: ylib.log_pf(item.name + " 发送不成功")
for item in mylist: item_id = get_strid(item["href"]) if(item_id > maxid): post_list.append(item) if(item_id > tmax): tmax = item_id ylib.log_pf("new news list length : " + str(len(post_list)) ); if len(post_list) > 0: ylib.log_pf("新增加新闻") for item in post_list: ylib.log_pf(item["text"].replace(".","") + " " + item["href"]) mystr = "<h3> ^V^ </h3>" for item in post_list: mystr += "<a href ='" + item["href"] + "'>"+ "<p>" + item["text"] + "</p>" + "</a>" if tmax != maxid: write_maxid(tmax) import my_email as me import user subject = "Fresh news in : " + str(ylib.get_now_time()) for item in user.users: import time time.sleep(5) if me.send_mail(item.email,subject,mystr) == 1: ylib.log_pf(item.name + " 发送成功") else: ylib.log_pf(item.name + " 发送不成功") if __name__ == "__main__": while(1): print ylib.get_now_time() ylib.log_pf("开始探测数据") cycle() ylib.log_pf("探测结束") print "探测结束" import time time.sleep(3600*6)