日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python淘宝cookies抢购_Python实现淘宝秒杀聚划算抢购自动提醒源码

發布時間:2025/3/11 python 18 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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)

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

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

總結

以上是生活随笔為你收集整理的python淘宝cookies抢购_Python实现淘宝秒杀聚划算抢购自动提醒源码的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。