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 ...
随机推荐
- ServerSocketChannel API用法
java.nio.channels 类 ServerSocketChannel java.lang.Object java.nio.channels.spi.AbstractInterruptible ...
- keepalived小结
keepalived 启动流程: 启动三个进程(主进程.healthcheck 进程.vrrp进程)之后,先进入backup状态,运行一次vrrp_script成功后发现没有主,这时候会进入maste ...
- 基于 Android NDK 的学习之旅-----数据传输(引用数据类型)
接着上篇文章继续讲.主要关于引用类型的数据传输,本文将介绍字符串传输和自定义对象的传输. 1.主要流程 1. String 字符串传输 a) 上层定义一个native的方法,需要一个 ...
- Git恢复删除或修改的文件 ls-files
一.git ls-files -d 查看删除了的文件 1.查看当前状态可以看到删除了一个index.js: git status image.png 2.查看当前项目中删除了的文件 git ls-fi ...
- java--css+js做的树形菜单(完整版)
jsp页面: <%@ page language="java" import="java.util.*" pageEncoding="UTF-8 ...
- Erlang 命令行监控工具
http://www.cnblogs.com/me-sa/archive/2012/11/22/erlang_vm_monitor_text_mode.html 之前介绍过一个Erlang的Web监控 ...
- 百度UEditor上传图片-再再总结一次
本周,CSDN有个网友遇到了百度UEditor上传问题,最后商定付50元钱,我帮他解决这个问题. 他最初想自己搞定这个问题,结果搞了好多次,好几天,还是没能解决. 2015年1月17日8: ...
- Oracle数据库零散知识02
15,函数的创建,要求必须有返回值,必须在语句中调用,需要多个返回值时,使用out参数类型,在user_procedures表中查询属性,在user_source表中查询源代码,创建示例: CREAT ...
- R 语言文件读写
1. working directory:工作目录 > getwd() > setwd("C:/data") # 设定当前工作目录 2. 读取格式化的 table &g ...
- Opencv目标跟踪—CamShift算法
CamShift算法全称是"Continuously Adaptive Mean-Shift"(连续的自适应MeanShift算法),是对MeanShift算法的改进算法,可以在跟 ...