代码就在下面,需要的自己验证即可,仅供学习参考
-----------------------------华丽非分割线-----------------------------
开个玩笑,做一次标题党,代码确实是没几行,因为是使用的dp,全程是drissionpage,下面是完整代码,本地试了几次也没啥太大问题
from DrissionPage import ChromiumPage, ChromiumOptions
from DrissionPage.common import Actions
import random,time
co = ChromiumOptions()
co.auto_port()
page = ChromiumPage(co)
page.get('验证码出现的地址')
ss = 253
ac = Actions(page)
page.wait.ele_loaded("xpath=//span[contains(@id,'nc_1_n1z')]")
page.ele("xpath=//span[contains(@id,'nc_1_n1z')]").hover()
ac.hold("xpath=//span[contains(@id,'nc_1_n1z')]")
ac.move(ss, duration=random.random())
time.sleep(random.random())
ac.release("xpath=//span[contains(@id,'nc_1_n1z')]")
page.quit()