Chrome浏览器驱动:https://registry.npmmirror.com/binary.html?path=chromedriver/
Edge游览器驱动:https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
import time
from selenium.webdriver import ActionChains
from selenium import webdriver
from selenium.webdriver.common.by import By
from Chaojiying_Python import chaojiying
from Chaojiying_Python.chaojiying import Chaojiying_Client
import user
wb=webdriver.Chrome()
wb.maximize_window()
wb.get('*******')
wb.find_element(by=By.XPATH,value='***').click()
time.sleep(3)
wb.find_element(by=By.XPATH,value='***').send_keys('***')
wb.find_element(by=By.XPATH,value='***').send_keys('***')
wb.find_element(by=By.XPATH,value='***').click()
time.sleep(5)
wb.find_element(by=By.XPATH,value='***').screenshot('123.png')
#定义一个函数 实现获得验证码位置
def autodis(a):
chaojiying = Chaojiying_Client(user.id, user.password, '*****')
im = open(a, 'rb').read()
return chaojiying.PostPic(im, ***)
data=autodis('123.png')
pic_list=data.get('pic_str').split('|')
#获得坐标为'49,280|59,172', 先使用|分割 得到['49,280','59,172']
#然后再使用,分割 得到(49,280)
#然后再转化为整数
#定义一个函数 实现获得每个字符的坐标并使用actionchain逐个点击
def autoclick(b):
imgned=wb.find_element(by=By.XPATH, value='//div[@class="geetest_holder geetest_silver"]')
for i in b:
f=i.split(",") #必须是双引号!!!
x=int(f[0])
y=int(f[1])
ActionChains(wb).move_to_element_with_offset(imgned,xoffset=x,yoffset=y).click().perform()
time.sleep(3)
wb.find_element(by=By.XPATH, value='//div[@class="geetest_commit_tip"]').click()
autoclick(pic_list)