python实现简单的whmcs补货通知

import requests
import time

pid=41  #替换为你想要监控的套餐pid

url='https://ion.krypt.com/cart.php?a=add&pid={pid}&promocode=iONWORDPRESS'.format(pid=pid)  #替换为监控的套餐地址


def sendmsg():
    print('发送通知')
    try:
        #调用 wx通知、邮件通知、网站通知等等
    except:
        pass

if __name__ == '__main__':
    flag=0
    while True:
        try:
            header={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36'}
            req=requests.get(url,headers=header).text

            if 'Out of Stock' in req:
                flag=0
                print('缺货,10秒后将再次检测')
            else:
                print('有货')
                if flag<3 :
                    sendmsg()
                    flag=flag+1
        except:
            pass

        time.sleep(10)

发表评论

邮箱地址不会被公开。 必填项已用*标注