#針對tableu 撰寫的大數據框架web
#tesseract 識別簡單的驗證碼chrome
很少說 直接上代碼框架
1 # coding:utf-8 2 from selenium import webdriver 3 from PIL import Image 4 import requests 5 from selenium.webdriver.common.by import By # 按照什麼方式查找,By.ID,By.CSS_SELECTOR 6 from selenium.webdriver.common.keys import Keys # 鍵盤按鍵操做 7 8 driver = webdriver.Chrome(r'C:\chromedriver\chromedriver.exe') 9 driver.get('http://IP+端口/jeecg/') 10 11 driver.save_screenshot('3.png') 12 element = driver.find_element_by_id("randCodeImage") 13 14 left = element.location['x'] 15 top = element.location['y'] 16 right = element.location['x'] + element.size['width'] 17 bottom = element.location['y'] + element.size['height'] 18 19 im = Image.open('3.png') 20 im = im.crop((left, top, right, bottom)) 21 im.save('3.png') 22 23 # bdbutton 24 import pytesseract 25 from PIL import Image 26 27 text = pytesseract.image_to_string(Image.open('3.png')) 28 print(text) 29 30 # 獲取輸入用戶名的地方 31 input_loginName = driver.find_element_by_id('userName') 32 # 清掉原先的內容 33 input_loginName.clear() 34 # 輸入用戶名 35 input_loginName.send_keys('用戶名') 36 # 獲取密碼 37 input_pwd = driver.find_element_by_id('password') 38 # 輸入密碼 39 input_pwd.send_keys('密碼') 40 # 得到驗證碼 41 input_yanzhengma = driver.find_element_by_id('randCode') 42 # 輸入驗證碼 43 input_yanzhengma.send_keys(text) 44 driver.maximize_window() 45 # 輸入回車 46 input_pwd.send_keys(Keys.ENTER) 47 import time 48 49 time.sleep(2) 50 # driver.switch_to.window(driver.window_handles[0]) 51 ####鼠標移動 52 import pyautogui 53 54 # pyautogui.doubleClick(111,232)#移動到某個點進行雙擊 55 pyautogui.click(572, 419) # 移動到某個點進行點擊 56 pyautogui.click(560, 490) 57 pyautogui.click(975, 527, duration=1) 58 59 time.sleep(3) 60 # 70 293 醫院動態 61 pyautogui.click(70, 275) 62 time.sleep(2) 63 # 100 335 實時 64 pyautogui.click(100, 335) 65 time.sleep(4) 66 # 100 428 實時動態 67 pyautogui.click(100, 428) 68 69 time.sleep(10) 70 71 # 600 274 72 pyautogui.click(600, 274) 73 ### 74 # 按下滾動軸 75 76 pyautogui.keyDown('pagedown') 77 pyautogui.keyDown('pagedown') 78 pyautogui.keyDown('pagedown') 79 80 # 449 819 點擊刷新 81 pyautogui.click(449, 819, duration=3) 82 time.sleep(20) 83 pyautogui.click(449, 819, duration=3)