说明:一般很多商家都喜欢使用whmcs
面板卖东西,特别是VPS
主机商,有时候很多服务器都是只卖一会就没了,很容易错过自己喜欢的VPS
,所以我们需要个监控,之前好像发过一个服务器库存监控教程,参考:PHP VPS库存监控系统搭建教程,不过经常要去看,有点不方便,这里再分享个VPS
库存监控教程,可以邮箱或者秘密导航a计划福利社入口,很方便。
以下脚本需要Python3
环境,一般大多数新系统都自带Python3
,使用python -V
命令可查看Python
版本,CentOS
升级教程参考:Linux CentOS升级Python 3.6版本方法。
秘密导航a计划亚洲日韩
本脚本基于python3
+sendmail
实现,这里只说CentOS
系统。注意邮件25
端口得打开,可能有的主机商会直接屏蔽25
端口,直接发工单要他开。
1、安装sendmail
yum install sendmail -y service sendmail start chkconfig sendmail on
2、下载并编辑脚本
wget https://www.moerats.com/usr/down/vpsyx.py
然后我们使用vi
命令编辑,将脚本中的url
里的网址换为其它whmcs
即可实现监控其它网址,不会使用vi
的,用FTP
软件比如WinSCP
登录VPS
后操作。
#脚本代码如下 from sys import argv from urllib import request from os import system try: flag=0 while True: url='https://einstein.enoctus.co.uk/cart.php?a=add&pid='+argv[1] 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=request.Request(url,headers=header) page=request.urlopen(req).read() with open('content.txt','w') as f: f.write('有货了,链接是:'+url) if str(page).find('out of stock')>0: flag=0 print('无货') else: flag=flag+1 print('有货') if flag<3: system("mail -s '有货了' {0}
3、使用
运行以下命令:
#pid为产品号,即链接最后面的数字 python vpsyx.py pid 邮箱
秘密导航a计划福利社入口
本脚本基于python3
+方糖实现免费推送。
1、下载脚本并编辑
wget https://www.moerats.com/usr/down/vpswx.py
然后我们使用vi
命令编辑,将脚本中的url
里的网址换为其它whmcs
即可实现监控其它网址,修改pid
为你想要监控的套餐pid
,并修改sckey
为你自己的方糖key
。不会使用vi
的,用FTP
软件比如WinSCP
登录VPS
后操作。
不知道方糖的,去Server
酱首页(https://sc.ftqq.com/),按照要求申请key
。
#脚本代码如下 from sys import argv from urllib import request,parse from os import system import datetime import time sckey="xxxxx" #替换为你自己的方糖key pid=93 #替换为你想要监控的套餐pid url='https://einstein.enoctus.co.uk/cart.php?a=add&pid=%s' % (pid) #替换为监控的套餐地址 try: flag=0 oktime=datetime.datetime.now() oktime.strftime('%Y-%m-%d %H:%M:%S') outoftime=datetime.datetime.now() outoftime.strftime('%Y-%m-%d %H:%M:%S') while True: 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=request.Request(url,headers=header) page=request.urlopen(req).read() if str(page).find('out of stock')>0: if flag>0: outoftime=datetime.datetime.now() outoftime.strftime('%Y-%m-%d %H:%M:%S') timeout='本轮次上货持续时间:%s' % (outoftime-oktime) print(timeout) tile='%s%s' % ('缺货提醒',timeout) textmod={'text':tile,'desp':url} textmod = parse.urlencode(textmod) urlsc='https://sc.ftqq.com/%s.send' % (sckey) req1=request.Request(url='%s%s%s' % (urlsc,'?',textmod),headers=header) page1=request.urlopen(req1).read() flag=0 print('缺货,10秒后将再次检测') time.sleep(10) else: if flag==0: oktime=datetime.datetime.now() oktime.strftime('%Y-%m-%d %H:%M:%S') timeok='本轮缺货持续时间:%s' % (oktime-outoftime) print(timeok) tile='%s%s' % ('上货提醒',timeok) textmod={'text':tile,'desp':url} textmod = parse.urlencode(textmod) urlsc='https://sc.ftqq.com/%s.send' % (sckey) req1=request.Request(url='%s%s%s' % (urlsc,'?',textmod),headers=header) page1=request.urlopen(req1).read() flag=flag+1 print('有货') if flag<3: tile='%s%s' % ('上货提醒',flag) textmod={'text':tile,'desp':url} textmod = parse.urlencode(textmod) urlsc='https://sc.ftqq.com/%s.send' % (sckey) req1=request.Request(url='%s%s%s' % (urlsc,'?',textmod),headers=header) page1=request.urlopen(req1).read() except: print('脚本异常,退出')
2、使用方法
运行以下命令:
python vpswx.py
文章来源:https://eqblog.com/whmcs-python-hon.html
方糖提供:http://www.hostloc.com/thread-422378-1-1.html