Python 实现 淘宝秒杀 聚划算 自己主动提醒 源代码
说明
本实施例可以监视一起购买的成本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 实现 淘宝秒杀 聚划算 自己主动提醒 源代码的更多相关文章
- Java 实现 淘宝秒杀 聚划算 自己主动提醒 源代码
说明 本实例可以监控聚划算的抢购button,在聚划算整点聚的时间到达时自己主动弹开页面(URL自定义). 能够自己定义监控持续分钟数,同一时候还能够通过多线程加快刷新速度. 源代码 package ...
- Python实现淘宝秒杀聚划算自动提醒源码
快来加入群[python爬虫交流群](群号570070796),发现精彩内容. 本实例能够监控聚划算的抢购按钮,在聚划算整点聚的时间到达时发出提醒(音频文件自己定义位置)并自动弹开页面(URL自己定义 ...
- python课件-淘宝-目录.txt
卷 TOSHIBA EXT 的文件夹 PATH 列表卷序列号为 AE86-8E8DF:.│ python课件-淘宝-目录.txt│ ├─01python核心编程阶段-linux基础(│ linux_h ...
- python3.4学习笔记(二十三) Python调用淘宝IP库获取IP归属地返回省市运营商实例代码
python3.4学习笔记(二十三) Python调用淘宝IP库获取IP归属地返回省市运营商实例代码 淘宝IP地址库 http://ip.taobao.com/目前提供的服务包括:1. 根据用户提供的 ...
- 淘宝数据库OceanBase SQL编译器部分 源代码阅读--Schema模式
淘宝数据库OceanBase SQL编译器部分 源代码阅读--Schema模式 什么是Database,什么是Schema,什么是Table,什么是列,什么是行,什么是User?我们能够能够把Data ...
- 淘宝数据库OceanBase SQL编译器部分 源代码阅读--生成物理查询计划
SQL编译解析三部曲分为:构建语法树,制定逻辑计划,生成物理运行计划. 前两个步骤请參见我的博客<<淘宝数据库OceanBase SQL编译器部分 源代码阅读--解析SQL语法树>& ...
- 淘宝数据库OceanBase SQL编译器部分 源代码阅读--生成逻辑计划
淘宝数据库OceanBase SQL编译器部分 源代码阅读--生成逻辑计划 SQL编译解析三部曲分为:构建语法树.生成逻辑计划.指定物理运行计划. 第一步骤,在我的上一篇博客淘宝数据库OceanBas ...
- python推荐淘宝物美价廉商品
完成的目标: 输入搜索的商品 以及 淘宝的已评价数目.店铺的商品描述(包括如实描述.服务态度.快递的5.0打分): 按要求,晒选出要求数量的结果,并按"物美价廉算法"排序后输出 思 ...
- python推荐淘宝物美价廉商品 2.0
改动: 新增功能 :可选择只看天猫或淘宝 代码模块化封装,参数配置或输入单独在一个py文件管理,主函数功能只留出参数传入在setting配置的py文件里. main.py代码: # -*- codin ...
随机推荐
- angular组件间的信息传递
原文 https://www.jianshu.com/p/82207f2249c1 大纲 1.父组件向子组件传递信息:通过属性 2.子组件向父组件传递信息:通过事件 3.父组件获取子组件的信息:通过调 ...
- tc
[em_Compare]cmd=d:\Apps\BeyondCompare4\now\BCompare.exeparam="""%X%P%S"" &q ...
- Spring Cloud底层原理
目录 一.业务场景介绍 二.Spring Cloud核心组件:Eureka 三.Spring Cloud核心组件:Feign 四.Spring Cloud核心组件:Ribbon 五.Spring Cl ...
- bash 提示用户输入 choice
read -p "Continue (y/n)?" choice case "$choice" in y|Y ) echo "yes";; ...
- [Angular] Ngrx/effects, Action trigger another action
@Injectable() export class LoadUserThreadsEffectService { constructor(private action$: Actions, priv ...
- Mybatis中sql语句中的in查询,一定要判断null的情况
不严谨的写法,可能会报错:in (),这种情况不符合mysql的语法. select from loanwhere LOAN_ID in <foreach item="item&quo ...
- Java 之 assert (断言)
我们知道C/C++语言中有断言的功能(assert).在Java SE 1.4版本以后也增加了断言的特性. 断言是为了方便调试程序,并不是发布程序的组成部分.理解这一点是很关键的. 默认情况下,JVM ...
- VNC不同用户 Oracle
VNC登录用户缺省是root,但在安装oracle时必须用oracle用户的身份登录,下面我们就以oracle为例说明如何配置VNC,从而可以使用不同的用户登录到主机.步骤描述如下: 步骤一:修 ...
- [_UICascadingTextStorage attributesAtIndex:effectiveRange:]: Range or index out of bounds
之前写过一篇<如何更好地限制一个UITextField的输入长度>,在文章最后得到的结论是可以直接使用 UIKIT_EXTERN NSString *const UITextFieldTe ...
- 【v2.x OGE-example 第一节】 绘制实体
前言: OGE即 OGEngine,是由橙子游戏开发的基于Java支持跨平台的开源游戏引,从12年4月项目成立至今已经有2年多的发展历程.在此期间基于OGEngine开发的项目已经有非常多成功投放市场 ...