luascrapy-splash

How to send a request from Splash via proxy?


I am trying to make a SplashRequest to a page using such a script:

function main(splash, args)
  splash:on_request(function(request)
    request:set_proxy{'http://login:password@host_proxy_ip:port'}
  end)
  assert(splash:go(args.url))
  assert(splash:wait(0.5))
  assert(splash:set_viewport_full())
  return {
    html = splash:html(),
    url = splash:url(),
  }
end

The page returns without errors, but my real ip is specified, where is my error?


Solution

  • found a working option:

    function main(splash, args)
              splash:on_request(function(request)
                request:set_proxy{
                  host = "host_proxy_ip",
                  port = port,
                  username = "login",
                  password = "password",
                  type = "HTTP"
                }
              end
              )
              assert(splash:go(args.url))
              assert(splash:wait(0.5))
              assert(splash:set_viewport_full())
              return {
                html = splash:html(),
                url = splash:url(),
              }
            end