说明

本实施例可以监视一起购买的成本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 实现 淘宝秒杀 聚划算 自己主动提醒 源代码的更多相关文章

  1. Java 实现 淘宝秒杀 聚划算 自己主动提醒 源代码

    说明 本实例可以监控聚划算的抢购button,在聚划算整点聚的时间到达时自己主动弹开页面(URL自定义). 能够自己定义监控持续分钟数,同一时候还能够通过多线程加快刷新速度. 源代码 package ...

  2. Python实现淘宝秒杀聚划算自动提醒源码

    快来加入群[python爬虫交流群](群号570070796),发现精彩内容. 本实例能够监控聚划算的抢购按钮,在聚划算整点聚的时间到达时发出提醒(音频文件自己定义位置)并自动弹开页面(URL自己定义 ...

  3. python课件-淘宝-目录.txt

    卷 TOSHIBA EXT 的文件夹 PATH 列表卷序列号为 AE86-8E8DF:.│ python课件-淘宝-目录.txt│ ├─01python核心编程阶段-linux基础(│ linux_h ...

  4. python3.4学习笔记(二十三) Python调用淘宝IP库获取IP归属地返回省市运营商实例代码

    python3.4学习笔记(二十三) Python调用淘宝IP库获取IP归属地返回省市运营商实例代码 淘宝IP地址库 http://ip.taobao.com/目前提供的服务包括:1. 根据用户提供的 ...

  5. 淘宝数据库OceanBase SQL编译器部分 源代码阅读--Schema模式

    淘宝数据库OceanBase SQL编译器部分 源代码阅读--Schema模式 什么是Database,什么是Schema,什么是Table,什么是列,什么是行,什么是User?我们能够能够把Data ...

  6. 淘宝数据库OceanBase SQL编译器部分 源代码阅读--生成物理查询计划

    SQL编译解析三部曲分为:构建语法树,制定逻辑计划,生成物理运行计划. 前两个步骤请參见我的博客<<淘宝数据库OceanBase SQL编译器部分 源代码阅读--解析SQL语法树>& ...

  7. 淘宝数据库OceanBase SQL编译器部分 源代码阅读--生成逻辑计划

    淘宝数据库OceanBase SQL编译器部分 源代码阅读--生成逻辑计划 SQL编译解析三部曲分为:构建语法树.生成逻辑计划.指定物理运行计划. 第一步骤,在我的上一篇博客淘宝数据库OceanBas ...

  8. python推荐淘宝物美价廉商品

    完成的目标: 输入搜索的商品 以及 淘宝的已评价数目.店铺的商品描述(包括如实描述.服务态度.快递的5.0打分): 按要求,晒选出要求数量的结果,并按"物美价廉算法"排序后输出 思 ...

  9. python推荐淘宝物美价廉商品 2.0

    改动: 新增功能 :可选择只看天猫或淘宝 代码模块化封装,参数配置或输入单独在一个py文件管理,主函数功能只留出参数传入在setting配置的py文件里. main.py代码: # -*- codin ...

随机推荐

  1. [HTML] Creating visual skip links in HTML and CSS

    Skip links are an extremely helpful navigation pattern for keyboard and screen reader users, since t ...

  2. Android多线程研究(8)——Java5中Futrue获取线程返回结果

    我们先来看一下ExecutorService中的执行方法: 在上一篇中我们使用了execute方法启动线程池中的线程执行,这一篇我们来看看submit方法的使用:submit提交一个返回值的任务用于执 ...

  3. C#生成6位随机验证码

    private string VerifyCode() { Random random = new Random(); , ).ToString(); }

  4. 打开cad文件的几种方法

    转自原文 打开cad文件的几种方法 IWorkspaceFactory pWorkspaceFactory; IFeatureWorkspace pFeatureWorkspace; IFeature ...

  5. [RxJS] Use RxJS concatMap to map and concat high order observables

    Like switchMap and mergeMap, concatMap is a shortcut for map() followed by a concatAll(). In this le ...

  6. JBoss AS 7之初步了解(The Return Of The King)

    watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvam9obl9mX2xhdQ==/font/5a6L5L2T/fontsize/400/fill/I0JBQk ...

  7. PHP移动互联网开发笔记(6)——文件的上传下载

    一.文件的上传 1.客户端设置: (1).在<form>标签中将enctype和method两个属性指明相应的值. Enctype="multipart/form-data&qu ...

  8. Spring学习笔记之六(数据源的配置)

    1.前言 上一篇博客分析了,Spring中实现AOP的两种动态代理的机制,以下这篇博客.来解说一下Spring中的数据源的配置.  2.DAO支持的模板类 Spring提供了非常多关于Dao支持的模板 ...

  9. [Ramda] Difference between R.converge and R.useWith

    So what is Point-free function. Take a look this example: const getUpdatedPerson = (person) => R. ...

  10. Android应用《撕开美女衣服》的实现过程及源代码

    现在很多Android市场中都能找到关于美女的应用,比如 撕开美女衣服.吹裙子等. 这些应用的下载量挺大的,作为Android的开发人员或者一名技术人员我们不能只局限在欣赏应用的层面,很多时候需要我们 ...