function main(splash, args) splash.images_enabled = false //不加载图片 assert(splash:go(args.url)) assert(splash:wait(1.5)) return { html = splash:html(), png = splash:png(), har = splash:har(), } end
<form id="login" action="/login"> <input type="text" name="username" /> <input type="password" name="password" /> <input type="checkbox" name="remember" /> <button type="submit">Submit</button> </form> function main(splash) -- ... local form = splash:select('#login') assert(form:fill({ username='admin', password='pass', remember=true })) assert(form:submit()) -- ... end
function main(splash, args) splash:set_viewport_size(800, 600) splash:set_user_agent('Splash bot') local example_urls = {"www.google.com", "www.bbc.co.uk", "scrapinghub.com"} local urls = args.urls or example_urls local results = {} for _, url in ipairs(urls) do local ok, reason = splash:go("http://" .. url) if ok then splash:wait(0.2) results[url] = splash:png() end end return results end
function main(splash, args) splash:set_user_agent('Mozilla') splash:add_cookie("_ujz", "MTc3ODc5Nzkw", "/", ".51job.com") assert(splash:go(args.url)) assert(splash:wait(0.5)) return { html = splash:html(), png = splash:png(), har = splash:har(), } end