Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

175
Visualizações
Returning multiple PNG images for each mouse_click

I'm trying to return multiple PNG images for each mouse_click. I've set it up so that I can get multiple coordinates of a click, and then store those coordinates in a table. Then, loop the keys/values of the table to get each click. However, when I run the entire function it only produces the first page produced by splash.args.url, and does not include the clicks inside the loop. How can I integrate the clicks inside the loop effectively to produce multiple images?

treat = require("treat")
function page_info(splash, url)
  local ok, msg = splash:go(url)
  if not ok then
    return {ok=false, reason=msg}
  end
  local res = {
    html=splash:html(),
    title=splash:evaljs('document.title'),
    image=splash:png(),
    ok=true,
  }
  return res
end
function main(splash)
    assert(splash:go(splash.args.url))
    local get_dimensions = splash:jsfunc([[
        function () {
var rect = document.querySelector('checkbox[number="1"]').getClientRects()[0];
var rect2 = document.querySelector('checkbox[number="2"]').getClientRects()[0];

    return {"x": rect.left, "y": rect.top,
  "x2": rect2.left, "y2": rect2.top}

        }
    ]])
    splash:set_viewport_full()
    splash:wait(0.1)
    local dimensions = get_dimensions()
    -- FIXME: button must be inside a viewport
  local stuff = {[dimensions.x]=dimensions.y,
  [dimensions.x2]=dimensions.y2}
  
  local result = treat.as_array({})
  local a = 1
  for keys, values in ipairs(stuff) do
    while a < 3 do
    splash:mouse_click(keys, values)
    a = a+1  
    result[a] = page_info(splash, url)
    end
  end
    -- Wait split second to allow event to propagate.
    splash:wait(0.1)
    return result
end

I can run each click successively, however how can I store the results of each click and return it?

As I get an empty array:

Splash Response: Array[0]

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda