如何从Scrapy Splash请求中生成cookie?

时间:2017-10-24 00:31:39

标签: python lua scrapy scrapy-splash splash-js-render

所以我做了一个像这样的Scrapy Splash请求:

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},)

问题是我如何获得使用lua脚本返回的cookie?

1 个答案:

答案 0 :(得分:2)

找到答案!在response.cookiejar

访问它