python實現自動搶課指令碼
import pyautogui
import time
import xlrd
import pyperclip
# 定義滑鼠事件
# duration 類似於移動時間或移動速度,省略後則是瞬間移動到指定的位置
def Mouse(click_times, img_name, retry_times):
if retry_times == 1:
location = pyautogui.locateCenterOnScreen(img_name, confidence=0.9)
if location is not None:
pyautogui.click(location.x, location.y, clicks=click_times, duration=0.2, interval=0.2)
elif retry_times == -1:
while True:
location = pyautogui.locateCenterOnScreen(img_name,confidence=0.9)
if location is not None:
pyautogui.click(location.x, location.y, clicks=click_times, duration=0.2, interval=0.2)
elif retry_times > 1:
i = 1
while i < retry_times + 1:
location = pyautogui.locateCenterOnScreen(img_name,confidence=0.9)
if location is not None:
pyautogui.click(location.x, location.y, clicks=click_times, duration=0.2, interval=0.2)
print(" 重複 {} 第 {} 次 ".format(img_name, i))
i = i + 1
# cell_value 1.0 :左鍵單擊
# 2.0 :輸入字串
# 3.0 :等待
# 4.0 :熱鍵
# 任務一:進行一輪搶課
def WorkFunction1(sheet):
i = 1
while i < sheet.nrows:
# 取 excel 表格中第 i 行操作
cmd_type = sheet.cell_value(i, 1)
# 1 :左鍵單擊
if cmd_type == 1.0:
# 獲取圖片名稱
img_name = sheet.cell_value(i, 2)
retry_times = 1
if sheet.cell_type(i, 3) == 2 and sheet.cell_value(i, 3) != 0:
retry_times =外匯跟單gendan5.com sheet.cell_value(i, 3)
Mouse(1, img_name, retry_times)
print(" 單擊左鍵 :{} Done".format(img_name))
# 2 :輸入字串
elif cmd_type == 2.0:
string = sheet.cell_value(i, 2)
pyperclip.copy(string)
pyautogui.hotkey('ctrl','v')
print(" 輸入字串 :{} Done".format(string))
# 3 :等待
elif cmd_type == 3.0:
wait_time = sheet.cell_value(i, 2)
time.sleep(wait_time)
print(" 等待 {} 秒 Done".format(wait_time))
# 4 :鍵盤熱鍵
elif cmd_type == 4.0:
hotkey = sheet.cell_value(i, 2)
# 防止重新整理過快停留在原網頁
time.sleep(1)
pyautogui.hotkey(hotkey)
print(" 按下 {} Done".format(hotkey))
time.sleep(1)
i = i + 1
# 任務二:蹲點等人退課
def WorkFunction2(sheet) :
while True:
WorkFunction1(sheet)
time.sleep(2)
if __name__ == '__main__':
start_time = time.time()
file = "info.xlsx"
# 開啟檔案
xr = xlrd.open_workbook(filename=file)
# 透過索引順序獲取表單
sheet = xr.sheet_by_index(0)
print("------ 歡迎使用自動搶課指令碼 ------")
print("---------@danteking---------")
print("1. 搶課一次 ")
print("2. 蹲點等人退課後搶指定課 ")
choice = input(">>")
start_time = time.time()
if choice == "1":
WorkFunction1(sheet)
elif choice == "2":
WorkFunction2(sheet)
else:
print(" 非法輸入,退出 ")
end_time = time.time()
time_consume = end_time - start_time
time_consume = ('%.2f' % time_consume)
print(" 耗時 {} 秒 ".format(time_consume))
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69946337/viewspace-2847951/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 利用 JS 指令碼實現網頁全自動秒殺搶購JS指令碼網頁
- 利用Python實現自動掃雷小指令碼Python指令碼
- python+selenium實現自動搶票Python
- 實現指令碼自動部署docker指令碼Docker
- 利用python實現批量自動化運維指令碼案例薦Python運維指令碼
- Oracle自動備份指令碼的實現Oracle指令碼
- dataguard switchover的自動化指令碼實現指令碼
- flyway實現java 自動升級SQL指令碼JavaSQL指令碼
- shell指令碼實現自動生成awr報告指令碼
- Python——自動簽到指令碼Python指令碼
- 教你用Python實現全自動刷網課Python
- 我用 Python 和 Twilio 實現自動化選課Python
- 實現MySQL表結構自動分割槽指令碼MySql指令碼
- 指令碼實現U盤自動掛載(linux)指令碼Linux
- SHELL指令碼實現Oracle自啟動與關閉指令碼Oracle
- ant指令碼實現的Android自動編譯指令碼Android編譯
- 《轉載》Jenkins持續整合-自動化部署指令碼的實現《python》Jenkins指令碼Python
- 使用 Fastlane 實現 iOS 跟 Android 自動打包指令碼ASTiOSAndroid指令碼
- rsync的自動指令碼實現方案(非rsyncd服務)指令碼
- Python課程程式碼實現Python
- 開機自動執行python指令碼Python指令碼
- Python3.6實現12306火車票自動搶票Python
- linux透過shell指令碼實現ssh互動式自動化Linux指令碼
- Python教你全自動搶微信紅包Python
- 自動ftp指令碼FTP指令碼
- 自動化瓦力多渠道打包python指令碼Python指令碼
- Python 轉義符以及指令碼自動生成Python指令碼
- 微信跳一跳指令碼重出江湖,python實現安卓&iOS自動版與手動版!指令碼Python安卓iOS
- 使用python實現memcached的啟動服務指令碼rcPython指令碼
- [shell]shell指令碼實現每天自動抽取資料插入hive表指令碼Hive
- specjvm自動化指令碼JVM指令碼
- 自動備份指令碼指令碼
- docker指令碼自動化Docker指令碼
- LNMP自動部署指令碼LNMP指令碼
- awr自動收集指令碼指令碼
- 自動化RMAN指令碼指令碼
- 用Python開發自動化測試指令碼Python指令碼
- 用 Python 指令碼實現電腦喚醒後自動拍照 截圖併發郵件通知Python指令碼