读取网页内容定时发到QQ群

https://github.com/pandolia/qqbot
QQBOT源码和使用方法
安装命令 pip install qqbot

# -*- coding: utf-8 -*-
from qqbot import qqbotsched
import time
import requests

@qqbotsched(hour='23,1,3,5,7,9,11,13,15,17,19,21', minute='1')
def mytask(bot):
    gl = bot.List('group', '微技')
    if gl is not None:
        for group in gl:
            bot.SendTo(group, text())

def text():
	yue = time.strftime('%m',time.localtime(time.time()))
	ri = time.strftime('%d',time.localtime(time.time()))
	dian = time.strftime('%H',time.localtime(time.time()))
	ws = http110()
	wendu = str(ws[0])
	shidu = str(ws[1])
	text = yue + '月' + ri + '日' + dian + '点 番禺机房巡检报告\r\n服务器交换机端口:无异常\r\n温度:' + wendu + '\r\n湿度:' + shidu + '\r\npdu、ups、空调正常'
	return text

def http110():
	try:
		res = requests.get('http://192.168.1.110/test.htm')
	except requests.exceptions.ConnectionError:
		return [28, 48]
	res.encoding = 'gbk'
	#print('长度:', len(res.text))
	if(len(res.text) >= 8000):
		htmlList = res.text.split('\n')
		listOne = []
		for i in range(len(htmlList)):
			if htmlList[i].find(']=') != -1:
				listOne.append(htmlList[i])
		listTwo = []
		if(len(listOne) == 120):
			for j in range(6*2*2):
				#print(listOne[11*2+j])
				if j % 2 != 0:
					tmp = listOne[11*2+j]
					tmp = tmp[12:14]
					#print(tmp)
					listTwo.append(tmp)
		if(len(listTwo) == 12):
			wendu = 0
			shidu = 0
			for k in range(len(listTwo)):
				if k % 2 == 0:
					wendu += int(listTwo[k])
					#print('温度 ' + listTwo[k])
				else:
					shidu += int(listTwo[k])
					#print('湿度 ' + listTwo[k])
		ret = []
		ret.append(str(wendu/6)[0:4])
		ret.append(str(shidu/6)[0:4])
	return ret

qq plug sample
加载插件命令

Windows Registry Editor Version 5.00
 ; Change Extension's File Type
 [HKEY_CURRENT_USER\Software\Classes\.jpg]
 @="PhotoViewer.FileAssoc.Tiff"
 ; Change Extension's File Type
 [HKEY_CURRENT_USER\Software\Classes\.jpeg]
 @="PhotoViewer.FileAssoc.Tiff"
 ; Change Extension's File Type
 [HKEY_CURRENT_USER\Software\Classes\.gif]
 @="PhotoViewer.FileAssoc.Tiff"
 ; Change Extension's File Type
 [HKEY_CURRENT_USER\Software\Classes\.png]
 @="PhotoViewer.FileAssoc.Tiff"
 ; Change Extension's File Type
 [HKEY_CURRENT_USER\Software\Classes\.bmp]
 @="PhotoViewer.FileAssoc.Tiff"
 ; Change Extension's File Type
 [HKEY_CURRENT_USER\Software\Classes\.tiff]
 @="PhotoViewer.FileAssoc.Tiff"
 ; Change Extension's File Type
 [HKEY_CURRENT_USER\Software\Classes\.ico]
 @="PhotoViewer.FileAssoc.Tiff"

解决win10照片查看器问题
读取网页内容定时发到QQ群_第1张图片

你可能感兴趣的:(python,QQ机器人)