I am trying to drag a captcha slider as presented in the site in splash using javascript an lua as shown in the below. I not able to run the script. I think the problem is javascript portion of my lua code.Specially getBoundingClientRect() in not properly executed. How can I run this code/drag the slider present in https://world.taobao.com/markets/all/sea/register .
function main(splash, args)--I am trying to drag the captcha slider present in the site https://world.taobao.com/markets/all/sea/registersplash:set_custom_headers({["Referer"] = "https://world.taobao.com/",["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36",["Origin"] = "https://reg.taobao.com"})assert(splash:go(args.url))assert(splash:wait(5.0))local get_slider_dimensions =splash:jsfunc([[function () {var rect = document.querySelectorAll("div#nc_1__scale_text span")[0].getBoundingClientRect();return {"x": rect.left, "y": rect.top,"width":rect.width}}]])splash:set_viewport_full()splash:wait(0.1)local slider_dimensions = get_slider_dimensions()splash:wait(0.1)splash:mouse_press(slider_dimensions.x, slider_dimensions.y)splash:mouse_release(slider_dimensions.x + slider_dimensions.width, slider_dimensions.y)return splash:png()end
I am trying to drag a captcha slider as presented in the site in splash using javascript an lua as shown in the below. I not able to run the script. I think the problem is javascript portion of my lua code.Specially
getBoundingClientRect()
in not properly executed. How can I run this code/drag the slider present in https://world.taobao.com/markets/all/sea/register .function main(splash, args)
--I am trying to drag the captcha slider present in the site https://world.taobao.com/markets/all/sea/register
splash:set_custom_headers(
{
["Referer"] = "https://world.taobao.com/",
["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36",
["Origin"] = "https://reg.taobao.com"
}
)
assert(splash:go(args.url))
assert(splash:wait(5.0))
local get_slider_dimensions =
splash:jsfunc(
[[
function () {
var rect = document.querySelectorAll("div#nc_1__scale_text span")[0].getBoundingClientRect();
return {"x": rect.left, "y": rect.top,"width":rect.width}
}
]]
)
splash:set_viewport_full()
splash:wait(0.1)
local slider_dimensions = get_slider_dimensions()
splash:wait(0.1)
splash:mouse_press(slider_dimensions.x, slider_dimensions.y)
splash:mouse_release(slider_dimensions.x + slider_dimensions.width, slider_dimensions.y)
return splash:png()
end