使用uibot RPA技术实现网站登录文字点选验证码验证
dim sImagePath = @res"Data\\sVerifyCode.jpg"
//验证码图片
dim
ImgEle =
{"html":{"tagName":"div","attrMap":{"css-selector":"body>div>div>div>div>div>form>div>div>div>div"},"index":2},"wnd":[{"app":"chrome","cls":"Chrome_WidgetWin_1","title":"*"},{"cls":"Chrome_RenderWidgetHostHWND","title":"Chrome
Legacy Window"}]}
//截图
UiElement.ScreenCapture(sImagePath,ImgEle,{"x":0,"y":0,"width":0,"height":0},{"bContinueOnError":false,"iDelayAfter":300,"iDelayBefore":200})
//请求超级鹰
sVerifyCode = GetVerificationCode(sImagePath,'账号','密码',9004)
dim list_temp = Split(sVerifyCode,"|") //根据“|”拆分字符串,存储为临时列表
//获取图片在屏幕坐标
dim
objRect =
UiElement.GetRect({"html":{"tagName":"img","attrMap":{"css-selector":"body>div>div>div>div>div>form>div>div>div>div>div>div>div>img"},"index":0},"wnd":[{"app":"chrome","cls":"Chrome_WidgetWin_1","title":"*"},{"cls":"Chrome_RenderWidgetHostHWND","title":"Chrome
Legacy
Window"}]},"screen",{"bContinueOnError":false,"iDelayAfter":300,"iDelayBefore":200})
For i = 0 To Len(list_temp)-1 step 1
// 获取文字坐标加上屏幕坐标
x = CInt(Split(list_temp[i],",")[0]) + CInt(objRect['x'])
y = CInt(Split(list_temp[i],",")[1]) + CInt(objRect['y'])
//移动鼠标模拟点击
Mouse.Move(x, y, false,{"iDelayAfter": 300, "iDelayBefore": 200})
Delay(1000)
Mouse.Click("left", "click", [],{"iDelayAfter": 300, "iDelayBefore": 300})
Next
//把附件放 在项目目录下 C:\项目名\extend\python
//在写个函数调用
Function GetVerificationCode(sImagePath,sChaoJiYingAccount,sChaoJiYingPassword,id)
Dim sVerificationCode = ""
Dim arrayVerificationCodeInfo = []
Try 3
id = cint(id)
//Log.Info("登录信息"&sChaoJiYingAccount&","&sChaoJiYingPassword&","&id&","&sImagePath)
arrayVerificationCodeInfo = chaojiying_utils.getCode(sChaoJiYingAccount,sChaoJiYingPassword,id,sImagePath)
Catch chaojiyingEx
Log.Info(chaojiyingEx)
Throw chaojiyingEx
End Try
sVerificationCode = arrayVerificationCodeInfo[1]
Return sVerificationCode
End Function
注意:使用的外部工具超级鹰