Python 实现 淘宝秒杀 聚划算 自己主动提醒 源代码
Python 实现 自己 源代码 主动 秒杀 淘宝 提醒
2023-09-11 14:21:01 时间
说明
本实施例可以监视一起购买的成本button,当警报济济一堂花费时间整点到达(音频文件自定义位置)而自己主动跳出页面(URL习惯)。
同一时候还能够通过命令行參数自己定义刷新间隔时间(默认0.1s)和监控持续时间(默认1800s)。
源代码
# encoding: utf-8 ''' @author: Techzero @email: techzero@163.com @time: 2014-5-18 下午5:06:29 ''' import cStringIO import getopt import time import urllib2 import subprocess import sys from datetime import datetime MEDIA_PLAYER = 'C:/Program Files/Windows Media Player/wmplayer.exe' MEDIA_FILE = 'D:/notify.mp3' CHROME = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe' URL = 'http://detail.ju.taobao.com/home.htm?spm=608.2214381.2.1.SY0wVT&item_id=16761325430&id=10000002801432' NO_X11 = False def get_current_button(): '''获取当前按钮状态''' content = urllib2.urlopen(URL).read() #获取页面内容 buf = cStringIO.StringIO(content.decode('gbk').encode('utf8')) #将页面内容转换为输入流 current_button = None for line in buf: line = line.strip(' \n\r') #去掉回车换行 if line.find(r'<a href="#" class="extra notice J_BuyButtonSub">开团提醒</a>') != -1: current_button = '开团提醒' break elif line.find(r'<div class="main-box chance ">') != -1: current_button = '还有机会' break elif line.find(r'<span class="out floatright">卖光了...</span>') != -1: current_button = '卖光了' break elif line.find(r'<span class="out floatright">已结束...</span>') != -1: current_button = '已结束' break elif line.find(r'<input type="submit" class="buyaction J_BuySubmit" title="立即抢" value="立即抢"/>') != -1: current_button = '立即抢' break buf.close() return current_button def notify(): '''发出通知并用Chrome打开秒杀页面''' subprocess.Popen([MEDIA_PLAYER, MEDIA_FILE]) if not NO_X11: subprocess.Popen([CHROME, URL]) print '打开页面' def monitor_button(interval, last): '''開始监视按钮''' elapse = 0 while elapse < last: current_button = get_current_button() now = datetime.now() print '%d-%d-%d %d:%d:%d - 如今按钮是 %s' % (now.year, now.month, now.day, now.hour, now.minute, now.second, current_button) if current_button == '立即抢' or current_button == '还有机会': print '赶紧抢购!' notify() break elif current_button == '卖光了' or current_button == '已结束': print '下次再试吧。' break else: print '还没開始呢,再等等吧!' time.sleep(interval) elapse += interval def usage(): print ''' usage: monitor_mac_price.py [options] Options: -i interval: 30 seconds by default. -l last: 1800 seconds by default. -h: Print this usage. -X: Run under no X11. ''' if __name__ == '__main__': try: opts, args = getopt.getopt(sys.argv[1:], 'i:l:hX') except getopt.GetoptError, err: print str(err) sys.exit(1) interval = 0.1 last = 1800 for opt, val in opts: if opt == '-i': interval = int(val) elif opt == '-l': last = int(val) elif opt == '-X': NO_X11 = True elif opt == '-h': usage() sys.exit() monitor_button(interval, last)
版权声明:本文博客原创文章。博客,未经同意,不得转载。
相关文章
- 第三百五十节,Python分布式爬虫打造搜索引擎Scrapy精讲—selenium模块是一个python操作浏览器软件的一个模块,可以实现js动态网页请求
- Python基于正则表达式实现文件内容替换的方法
- 【Python】python对象与json相互转换
- Atitit. servlet 与 IHttpHandler ashx listen 和HttpModule的区别与联系 原理理论 架构设计 实现机制 java php c#.net js javascript c++ python
- Python的IDE:基于Eclipse/MyEclipse软件的PyDev插件配置python的开发环境(不同python项目加载不同版本的python)—从而实现Python编程图文教程之详细攻略
- Python语言学习:Python语言学习之python包/库package的简介(模块的封装/模块路径搜索/模块导入方法/自定义导入模块实现华氏-摄氏温度转换案例应用)、使用方法、管理工具之详细攻略
- Python:利用python语言实现18位身份证号码和15位身份证号码相互转换
- Python编程语言学习:python的列表的特殊应用之一行命令实现if判断中的两类判断
- Python编程语言学习:python的列表的特殊应用之一行命令实现if判断中的两类判断
- Python的IDE:基于Eclipse/MyEclipse软件的PyDev插件配置python的开发环境(不同python项目加载不同版本的python)—从而实现Python编程图文教程之详细攻略
- 已解决2.Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and wi
- 已解决2. Set PROTOCOL_BUPFERS_PYTHON_iMPLEMENTATION=python (but this will use pure-Python parsing and w
- python你实现视频自动打码,了解妨碍你观看精彩的马赛克是怎么精准形成的
- Python 采集 筷 实现视频批量保存
- Python实现哈里斯鹰优化算法(HHO)优化循环神经网络分类模型(LSTM分类算法)项目实战
- Python实现ABC人工蜂群优化算法优化支持向量机回归模型(SVR算法)项目实战
- Python编程:Flask-BasicAuth实现Authentication登录认证
- Python实现的十进制小数与二进制小数相互转换功能
- N叉树的深度 python实现
- python deque的内在实现 本质上就是双向链表所以用于stack、队列非常方便
- python基础===一行 Python 代码实现并行(转)
- 表弟学完Python靠接单兼职,实现了经济独立!
- 〖Python自动化办公篇⑲〗 - python实现邮件自动化 - 邮件发送
- 【Python】3.python实现图片上传到阿里云OSS