使用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,'用户名','用户密码',9101)
Log.Info(sVerifyCode)
//滑块在页面上的坐标
dim objRect = UiElement.GetRect({"html":{"tagName":"div","attrMap":{"css-selector":"body>div>div>div>div>div>form>div>div>div>div>div>div>div>div"},"index":2},"wnd":[{"app":"chrome","cls":"Chrome_WidgetWin_1","title":"*"},{"cls":"Chrome_RenderWidgetHostHWND","title":"Chrome Legacy Window"}]},"screen",{"bContinueOnError":false,"iDelayAfter":300,"iDelayBefore":200})
Log.Info(objRect)
//技术拼图凹槽位置 (这里这个30是拼图与滑块的边距 可根据自己边调试)
x = (CInt(objRect['x']) - 30) + CInt(Split(sVerifyCode,",")[0])
Log.Info(x)
//模拟拖动
Mouse.Drag(CInt(objRect['x']), objRect['y'], x, objRect['y'], "left", [],{"iDelayAfter": 300, "iDelayBefore": 200})
//把附件放 在项目目录下 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
注意:使用的外部工具超级鹰