python淘寶cookies搶購_Python實現淘寶秒殺聚劃算搶購自動提醒源碼

說明

本實例能夠監控聚劃算的搶購按鈕,在聚劃算整點聚的時間到達時發出提醒(音頻文件自己定義位置)并自動彈開頁面(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'開團提醒') != -1:

current_button = '開團提醒'

break

elif line.find(r'

') != -1:

current_button = '還有機會'

break

elif line.find(r'賣光了...') != -1:

current_button = '賣光了'

break

elif line.find(r'已結束...') != -1:

current_button = '已結束'

break

elif line.find(r'') != -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)

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持萬仟網。

如您對本文有疑問或者有任何想說的,請點擊進行留言回復,萬千網友為您解惑!

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/542623.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/542623.shtml
英文地址,請注明出處:http://en.pswp.cn/news/542623.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

kadane算法_使用KADANE的算法求最大子陣列和

kadane算法What is a sub-array? 什么是子陣列&#xff1f; A sub-array is basically an arrays contiguous part. For example, if we have an array of integers [1,2,3] so the sub-arrays that we can form from the given array are [1], [2] , [3] , [1,2] , [2,3] , …

java汽車油耗計算_轉發一個手機油耗計算器 (java)

今天在一個汽車論壇上看見的&#xff0c;試了試&#xff0c;還真不錯。比以前那個Fuel Consumption 功能要強大,雖然都是JAVA軟件。小羅盤手機計算器是作者獨自產品策劃、美術設計、程序開發、測試發布的手機應用軟件&#xff0c;是為作者的一個朋友寫的&#xff0c;當然我們用…

6.dubbo常用的xml配置有哪些_【面試篇】必須掌握的Spring 常用注解

閱讀文本大概需要5分鐘。注解本身沒有功能的&#xff0c;就和 xml 一樣。注解和 xml 都是一種元數據&#xff0c;元數據即解釋數據的數據&#xff0c;這就是所謂配置。本文主要羅列 Spring|Spring MVC相關注解的簡介。Spring部分1、聲明bean的注解Component 組件&#xff0c;沒…

Linux的iptables常用配置范例(2)

iptables -F #清除所有規則 iptables -X #清除所有自定義規則 iptables -Z #各項計數歸零 iptables -P INPUT DROP #將input鏈默認規則設置為丟棄 iptables -P OUTPUT DROP #將output鏈默認規則設置為丟棄 iptables -A INPUT -i lo -j ACCEPT iptables -A OUTPUT -o lo …

aptitude 命令_C-命令行參數Aptitude問題與解答

aptitude 命令C programming Command Line Arguments Aptitude Questions and Answers: In this section you will find C Aptitude Questions and Answers on Command Line Arguments – Passing values with running programs, separate argument values, number of argument…

文件上傳java邏輯_Java?文件上傳?實例

import java.io.*;import java.util.*;import javax.servlet.*;import javax.servlet.http.*;public class Upload {private String saveDir "."; // 要保存文件的路徑private String contentType ""; // 文檔類型private String charset "";…

matlab數值計算pdf_Gnuplot科學繪圖(九)——柵格以及方程數值解估算

Gnuplot科學繪圖系列內容Gnuplot科學繪圖(一)——從安裝到簡單函數繪圖(文末有彩蛋)Gnuplot科學繪圖(二)——坐標取值范圍及刻度(文末有彩蛋)Gnuplot科學繪圖(三)——點線風格Gnuplot科學繪圖(四)——多組數據繪圖Gnuplot科學繪圖(五)——輸出eps 圖片Gnuplot科學繪圖(六)——輸…

dda算法_計算機圖形學中的DDA(數字差分分析儀)算法

dda算法DDA(數字差分分析儀)算法 (DDA (Digital Differential Analyzer) Algorithm) In computer graphics, the DDA algorithm is the simplest algorithm among all other line generation algorithms. Here, the DDA is an abbreviation that stands for "Digital Diff…

購物商城框架java_基于jsp的購物商城-JavaEE實現購物商城 - java項目源碼

基于jspservletpojomysql實現一個javaee/javaweb的購物商城, 該項目可用各類java課程設計大作業中, 購物商城的系統架構分為前后臺兩部分, 最終實現在線上進行購物商城各項功能,實現了諸如用戶管理, 登錄注冊, 權限管理等功能, 并實現對各類購物商城相關的實體進行管理。該購物…

c語言++數組名【數字】_C ++程序在數組中打印所有非重復數字

c語言數組名【數字】Problem statement: Write a C program to print all the non-repeated numbers in an array in minimum time complexity. 問題陳述&#xff1a;編寫一個C 程序&#xff0c; 以最小的時間復雜度將所有未重復的數字打印在數組中 。 Input Example: 輸入示例…

java最接近對點及距離_最接近點對問題_分治法

一、問題描述給定平面上的n個點&#xff0c;找其中的一對點&#xff0c;使得在n個點組成的所有點對中該點對間的距離最小。二、解題思路及所選算法策略的可行性分析思路&#xff1a;利用分治法來解決問題。遞歸子結構求最接近點對總體可分為幾個步驟&#xff1a;1、當問題規模小…

python return用法_初學Python要了解什么 裝飾器知識匯總有哪些

初學Python要了解什么&#xff1f;裝飾器知識匯總有哪些&#xff1f;在Python學習過程中&#xff0c;有多種方法對函數和類進行加工&#xff0c;相對于其它方式&#xff0c;裝飾器語法簡單&#xff0c;代碼可讀性高。因此&#xff0c;裝飾器在Python項目中有廣泛的應用&#xf…

android emulator虛擬設備分析第三篇之pipe上的qemud service

一、概述 本篇和第二篇是強相關的&#xff0c;需要結合第二篇一起看。 以boot-properties為例&#xff0c;注意不需要看ANDROID-QEMUD.TXT&#xff0c;這個是和guest os中的qemud進行相關的&#xff0c;已廢棄。 啟動emulator時&#xff0c;有一個參數-prop <key><val…

c#異常處理_C#異常處理能力問題和解答 套裝4

c#異常處理1) Which is not a valid keyword used in the context of exception handling? trycatchfinalfinally Answer & Explanation Correct answer: 3final The final keyword is not used to handle exceptions in C#.NET. 1)在異常處理的上下文中使用哪個無效關鍵字…

Castor xsd生成java_java – Castor可以處理從基礎XSD導入的多個XSD生成類嗎?

注意&#xff1a;我是EclipseLink JAXB (MOXy)領導者,也是JAXB 2 (JSR-222)專家組的成員.Can Castor do this? If so, what would be the Ant task syntax for it.If not, would perhaps JAXB be a better alternative?下面是如何使用JAXB完成此操作的示例&#xff1a;產品xm…

串口通信 校驗碼_一文讀懂S7-200 SMART自由口通信!

學習S7-200 SMART時了解到&#xff0c;基于RS485接口可實現一下幾種通信&#xff1a;1&#xff09;modbus RTU通信2&#xff09;PPI協議通信3&#xff09;USS協議通信4&#xff09;自由口通信何為自由口通信呢&#xff1f;前三種通信必須要PLC和與其通信的設備支持相同的通信協…

hbase 學習(十三)集群間備份原理

集群建備份&#xff0c;它是master/slaves結構式的備份&#xff0c;由master推送&#xff0c;這樣更容易跟蹤現在備份到哪里了&#xff0c;況且region server是都有自己的WAL 和HLog日志&#xff0c;它就像mysql的主從備份結構一樣&#xff0c;只有一個日志來跟蹤。一個master集…

python expect模塊_Python基礎教程:用Python怎么telnet到網絡設備

Python基礎教程&#xff1a;用Python怎么telnet到網絡設備0.前言Telnet協議屬于TCP/IP協議族里的一種&#xff0c;對于我們這些網絡攻城獅來說&#xff0c;再熟悉不過了&#xff0c;常用于遠程登陸到網絡設備進行操作&#xff0c;但是&#xff0c;它的缺陷太明顯了&#xff0c;…

Java實現動態加載頁面_[Java教程]動態加載頁面數據的小工具 javascript + jQuery (持續更新)...

[Java教程]動態加載頁面數據的小工具 javascript jQuery (持續更新)0 2014-05-07 18:00:06使用該控件&#xff0c;可以根據url&#xff0c;參數&#xff0c;加載html記錄模板(包含json參數對應&#xff0c;以及具體記錄位置Index根據參數描述加載對應的屬性&#xff0c;并可以…

馬哥linux第六周作業

1、復制/etc/rc.d/rc.sysinit文件至/tmp目錄&#xff0c;將/tmp/rc.sysinit文件中的以至少一個空白字符開頭的行的行首加#&#xff1b;[rootmageedu tmp]# cp /etc/rc.d/rc.sysinit . [rootmageedu tmp]# vim rc.sysinit :% s/^[[:space:]]/#&/ #按Esc進入vi…