Search code examples
pythonluascrapyscrapy-splashsplash-js-render

How to get cookie generated from a Scrapy Splash request?


So I have made a Scrapy Splash request like this:

def start_requests(self):
    lua_script = '''
    function main(splash)
      local url = splash.args.url
      assert(splash:go(url))
      assert(splash:wait(0.5))
      return {
        cookies = splash:get_cookies(),
      }
    end
    '''
    yield SplashRequest(self.start_urls[0], self.parse,
            endpoint='render.html',
            args={'wait': 1, 'lua_source': lua_script},)

The problems is how do I get the cookies that I've set to be returned using the lua script?


Solution

  • Found the answer! Access it at response.cookiejar