Skip to content

Instantly share code, notes, and snippets.

@Glowin
Created January 11, 2018 06:16
Show Gist options
  • Save Glowin/8237e54388f00c0fa4e90946643906b0 to your computer and use it in GitHub Desktop.
Save Glowin/8237e54388f00c0fa4e90946643906b0 to your computer and use it in GitHub Desktop.
自动监测 VVPool 矿池的矿机,如果掉线立即发送微信提醒
# -*- coding: utf-8 -*-
# 0. 安装 python 2.7 和 beautifulSoup https://www.crummy.com/software/BeautifulSoup/bs4/doc/
# 1. url 参数填写你的 VVPool 钱包主页地址,暂时只支持 VVPool
# 2. http://sc.ftqq.com/ 完成账号绑定后,在 http://sc.ftqq.com/?c=code 拿到 key
# 3. 更新文件同步在QQ群:617042593
from bs4 import BeautifulSoup
import requests
import time
url = "http://www.vvpool.com/bitcoin-pizza/XXXXXXXXXXXXXXXXXXXXX"
key = "SCU19780TXXXXXXXXXXXXXXXXXXXXXX577b1f5a5318671518e"
def get_bpa_price():
r = requests.get(url)
html = r.text
soup = BeautifulSoup(html, "lxml")
data_html = soup.find_all("span", "item-value")
if data_html is not None and len(data_html) > 0:
total_bpa = data_html[2].string
else:
total_bpa = 0
return float(total_bpa)
def send_wechat( title, desp ):
requests.get("https://sc.ftqq.com/"+ key + ".send?text=" + title + "&desp=" + desp);
send_wechat("monitor_is_runing!!!!", "Go_Go_Go!!!")
print "Monitor is runing!!!"
bpa_buff = get_bpa_price()
print bpa_buff
timer_buff = 0
while 1 :
time.sleep(60)
current_bpa = get_bpa_price()
print current_bpa
if current_bpa == bpa_buff:
if timer_buff // 10 == 1 :
send_wechat("Miner_is_not_work_for_10_mins", "Please_check_the_Teamviewer")
timer_buff += 1
bpa_buff = current_bpa
continue
elif timer_buff // 10 > 1:
timer_buff += 1
bpa_buff = current_bpa
continue
else:
send_wechat("Miner_is_not_work", "Please_check_the_Teamviewer")
bpa_buff = current_bpa
timer_buff += 1
else:
timer_buff = 0
bpa_buff = current_bpa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment