本帖最后由 ivor 于 2016-2-20 09:33 编辑
- # python 3.5.1
- # coding:utf-8
- # 检测bathome.net论坛是否有新话题或者新回复,窗口闪烁提示
- # by:ivor bathome.net
-
- import ctypes, time, urllib.request, re
-
- # 访问网站函数
- def accweb(websit):
- data = urllib.request.urlopen(websit)
- webdata = data.read()
- webdata = webdata.decode("gbk")
- search = re.findall(r'<td valign="top".*?td>', webdata, re.S)
- return search
-
- # 创建user32实例,方便后面调用
- user32 = ctypes.windll.LoadLibrary("user32")
- # 获取当前窗口句柄
- hWnd = user32.GetForegroundWindow()
- old = accweb("http://www.bathome.net")
- # 循环读取
- while True:
- new = accweb("http://www.bathome.net")
- if old == new:
- user32.SetWindowTextA(hWnd,b" Normal Monitoring.....")
- else:
- user32.FlashWindow(hWnd,True)
- old = new
- time.sleep(15)
复制代码
|