pyttsx3 winsound win32api.MessageBox使用案例

import requests,time
from lxml import etree
import win32api,win32con
import winsound
import pyttsx3

cookies = str(input('請輸入cookies:'))

def ring():
    engine = pyttsx3.init()
    engine.say('傻逼,有戶了,趕忙去搶')
    engine.runAndWait()

def check_account():
    today = time.strftime('%Y-%m-%d',time.localtime())
    url1 = 'http://cm.admin.weibo.com/customer_base/customer_base.php?hiddenuid=2&exportuid=&uid=&nickname=&start_storage_time={}&end_storage_time=+{}+&type_status=2&source=&start_open_time=&end_open_time=&filed=0&industry=0&one_industry=0&region=0&one_region=0'
    headers ={'Cookie': cookies,
    'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36',
    'Host': 'cm.admin.weibo.com',
    }
    time.sleep(3)
    res = requests.get(url1.format(today,today),headers=headers)
    html = etree.HTML(res.text)
    html_data = html.xpath('//*[@id="listTable"]/tbody/tr/td[3]/text()')
    if len(html_data) >0:
        print('哈哈傻逼,出來' + str(len(html_data)) + '個戶,趕忙搶,他們是:'+ ','.join(html_data))
        win32api.MessageBox(win32con.NULL,'哈哈傻逼,出來' + str(len(html_data)) + '個戶,趕忙搶,他們是:'+ ','.join(html_data) , '有戶了,快特麼領去', win32con.MB_OK)
        winsound.Beep(600,500)
        ring()
        return True
    else:
        print('沒有戶')
        return False

if __name__ == '__main__':
    count = 1
    while True:
        todayHS = time.strftime('%Y-%m-%d %H:%M:%S',time.localtime())
        print('時間:%s 第 %s 次查詢-----> '% (todayHS,str(count)),end='')
        flag=check_account()
        if flag is True:
            break
        count +=1
相關文章
相關標籤/搜索