1. Splash_Lua脚本

1.1. 在docker中启动Splash

docker run -p 8050:8050 scrapinghub/splash

1.2. Demo1

function main(splash,args)
    splash:go("https://www.baidu.com")
    input=splash:select("#kw")
    input:send_text("Splash")
    submit=splash:select("#su")
    submit.mouse_click()
    splash:wait(3)
    return splash:png()
end

1.3. Demo2

function main(splash,args)
    local treat=require('treat')
  assert(splash:go("http://quotes.toscrape.com/"))
  assert(splash:wait(0.5))
  local texts=splash:select_all(".quote .text")
  local results={}
  for index,text in ipairs(texts) do
    results[index] = text.node.innerHTML
  end
  return treat.as_array(results),splash:png()
end
Copyright © AGou 2020 all right reserved,powered by Gitbook该文件修订时间: 2020-05-06 05:23:14

results matching ""

    No results matching ""