如何获取从 Scrapy Splash 请求生成的 cookie?
How to get cookie generated from a Scrapy Splash request?
所以我做了这样一个 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?
找到答案了!在 response.cookiejar
访问它
所以我做了这样一个 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?
找到答案了!在 response.cookiejar