• python模拟大数据登陆


    #针对tableu 撰写的大数据框架

    #tesseract 识别简单的验证码

    不多说  直接上代码

     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:chromedriverchromedriver.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)
    View Code
  • 相关阅读:
    POJ 1044: Date bugs
    POJ 1017: Packets
    POJ 1014: Dividing
    POJ 1012: Joseph
    POJ 1011: Sticks
    POJ 1008: Maya Calendar
    POJ 1005: I Think I Need a Houseboat
    为什么要自动化测试
    微软CodeDom模型学习笔记(全)
    概念完整性
  • 原文地址:https://www.cnblogs.com/nodchen/p/10787913.html
Copyright © 2020-2023  润新知