Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions splash/examples/proxyEg.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
function main(splash)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think "use-proxy.lua" would be a better name (the convention in the examples/ folder is to use dash-separated file name, not camel case).

splash:on_request(function(request)
request:set_proxy{
host = "10.3.100.207",
port = 8080,
username = splash.args.username,
password = splash.args.password,
}
end)
local url = splash.args.url
assert(splash:go(url))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't make sense to create a local variable and only use it once. Simply assert(splash:go(splash.args.url)) would do.

assert(splash:wait(0.5))
return {
html = splash:html(),
png = splash:png(),
har = splash:har(),
}
end