PYTHON自動登錄+定點點擊(水貨版)
--coding:utf-8--
import time
import pytesser3
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import selenium.webdriver.support.ui as ui
from selenium.webdriver.common.action_chains import ActionChains
from PIL import Image,ImageEnhance
from pymouse import PyMouse
time.sleep(1)
browser = webdriver.Firefox()
browser.get(‘URL/‘)
eles = browser.find_element_by_name("username")
eles.send_keys("user")
elem = browser.find_element_by_name("password")
elem.send_keys("passwd")
browser.get_screenshot_as_file(‘D:/pic/image1.png‘) # 比較好理解
box = (941, 600, 1095, 650) # 設置要裁剪的區域
region = im.crop(box) # 此時,region是一個新的圖像對象。
region.save("D:/pic/image_code.png")
im = Image.open("D:/pic/image_code.png")
imgry = im.convert(‘L‘) # 圖像加強,二值化
sharpness = ImageEnhance.Contrast(imgry) # 對比度增強
sharp_img = sharpness.enhance(2.0)
im = Image.open(‘D:/pic/image_code1.png‘)
im.show()
SecretCode = input(‘please enter the code: ‘)
elem = browser.find_element_by_name("verifyCode")
elem.send_keys((SecretCode))
elem.send_keys(Keys.ENTER)
browser.maximize_window()
#mop自動修改
time.sleep(3)
k = PyKeyboard()
m = PyMouse()
m.click(72, 411) #點擊運單查詢
time.sleep(1)
m.click(84, 623) #點擊MOP異常處理
time.sleep(3)
m.click(377, 275) #點擊下單開始時間
time.sleep(1)
m.click(350, 308) #前選一年
time.sleep(1)
m.click(486, 383) #確定
#開始循環點擊,定義數組
a=("080927107021",
)
for y in a:
m.click(357, 309)
time.sleep(1)
k.press_keys([k.control_l_key, ‘a‘])
time.sleep(1)
k.tap_key(k.delete_key)
time.sleep(1)
k.type_string((y))
m.click(257, 343)
time.sleep(2)
m.click(248, 575)
time.sleep(2)
m.click(1731, 578)
time.sleep(2)
m.click(465, 348)
time.sleep(3)
m.click(1036, 610)
time.sleep(1)
PYTHON自動登錄+定點點擊(水貨版)