예제 #1
0
    open('maxTicket.txt', 'w')
# 如果文件夹updated不存在,则新建文件夹
parent_path = os.getcwd()
path = parent_path+'/updated/'
if not os.path.exists(path):
    os.mkdir(path)
for item in myTicket:
    #print item
    # 处理新Ticket,读取文本文件里的max, 遍历ticket,然后和max比较,如果ticket>max,修改max,发送邮件
    m_handler = open('maxTicket.txt', 'r')
    max = m_handler.readline()
    if item[0] > max:
        m_handler = open('maxTicket.txt', 'w')
        m_handler.write(item[0])
        m_handler.close()
        if mail.sendTxtMail(mailto_list, "新任务New Ticket "+item[0]+" Come In", "Hello CTANG,<br /><p>有一个新的Ticket "+item[0]+", 请及时处理!</p><p>http://tickets.theportalgrp.com/rt/Ticket/Display.html?id="+item[0]+"</p>"):
            print getCurrentTime() + " New Ticket "+item[0]+" 提醒邮件发送成功!"
        else:
            print getCurrentTime() + " New Ticket "+item[0]+" 提醒邮件发送失败!"
    else:
        print getCurrentTime() + " 没有新的Ticket信息!"
    # 处理最新更新
    realLatestUpdated = getLatestUpdated(detail_url+item[0])
    updatedBy = realLatestUpdated.split('by')[1].strip()
    #print updatedBy
    if os.path.exists(path+item[0]):
        l_handler = open(path+item[0], 'r')
        savedLastUpdated = l_handler.readline()
        if savedLastUpdated != '':
            if realLatestUpdated != savedLastUpdated:
                # 获取最新一条更新信息
예제 #2
0
                stockTime = stockInfo.find_all(
                    attrs={'class': 'state'})[0].text.split()[2]

                # 汉字转换成拼音
                stockName_pinyin = p.get_initials(stockName, u'')

                price_class = soup.find('div', attrs={'class': 'price'})
                # 当前价格
                current_price = price_class.strong.string

                # 达到设定高值发送邮件
                for k, v in stock_alert_value_high.items():
                    if k == stockName:
                        if float(current_price) >= v:
                            if mail.sendTxtMail(
                                    mailto_list, k + "卖出提醒-" + current_price,
                                    k + "上涨到" + current_price + "了。"):
                                pass
                                # print(k+" 提醒邮件发送成功!")
                            else:
                                pass
                                # print(k+" 提醒邮件发送失败!")
                        else:
                            pass
                            # print(k+" 未达预设值")
                # 达到设定低值
                for k, v in stock_alert_value_low.items():
                    if k == stockName:
                        if float(current_price) <= v:
                            if mail.sendTxtMail(
                                    mailto_list, k + "买入提醒-" + current_price,
예제 #3
0
            stockInfo = soup.find('div', attrs={'class':'stock-bets'})
            stockName = stockInfo.find_all(attrs={'class':'bets-name'})[0].text.split()[0]
            stockTime = stockInfo.find_all(attrs={'class': 'state'})[0].text.split()[2]

            # 汉字转换成拼音
            stockName_pinyin = p.get_initials(stockName, u'')

            price_class = soup.find('div', attrs={'class':'price'})
            # 当前价格
            current_price = price_class.strong.string

            # 发送邮件
            for k, v in stock_alert_value_high.items():
                if k == stockName:
                    if float(current_price) >= v:
                        if mail.sendTxtMail(mailto_list, k+"卖出提醒", k+"上涨到设定值了。"):
                            pass
                            # print(k+" 提醒邮件发送成功!")
                        else:
                            pass
                            # print(k+" 提醒邮件发送失败!")
                    else:
                        pass
                        # print(k+" 未达预设值")

            price_range = price_class.find_all('span')
            # 价格变化值
            change_price = price_range[0].string
            # 价格变化幅度
            change_rate = price_range[1].string
예제 #4
0
parent_path = os.getcwd()
path = parent_path + '/updated/'
if not os.path.exists(path):
    os.mkdir(path)
for item in myTicket:
    #print item
    # 处理新Ticket,读取文本文件里的max, 遍历ticket,然后和max比较,如果ticket>max,修改max,发送邮件
    m_handler = open('maxTicket.txt', 'r')
    max = m_handler.readline()
    if item[0] > max:
        m_handler = open('maxTicket.txt', 'w')
        m_handler.write(item[0])
        m_handler.close()
        if mail.sendTxtMail(
                mailto_list, "新任务New Ticket " + item[0] + " Come In",
                "Hello CTANG,<br /><p>有一个新的Ticket " + item[0] +
                ", 请及时处理!</p><p>http://tickets.theportalgrp.com/rt/Ticket/Display.html?id="
                + item[0] + "</p>"):
            print getCurrentTime() + " New Ticket " + item[0] + " 提醒邮件发送成功!"
        else:
            print getCurrentTime() + " New Ticket " + item[0] + " 提醒邮件发送失败!"
    else:
        print getCurrentTime() + " 没有新的Ticket信息!"
    # 处理最新更新
    realLatestUpdated = getLatestUpdated(detail_url + item[0])
    updatedBy = realLatestUpdated.split('by')[1].strip()
    #print updatedBy
    if os.path.exists(path + item[0]):
        l_handler = open(path + item[0], 'r')
        savedLastUpdated = l_handler.readline()
        if savedLastUpdated != '':