1
我正在使用scrapy +飛濺插件,我有一個按鈕,通過ajax觸發下載事件,我需要獲取下載的文件,但不知道如何。從js點擊事件的Scrapy飛濺下載文件
我的LUA腳本是一樣的東西從我的蜘蛛這個
function main(splash)
splash:init_cookies(splash.args.cookies)
assert(splash:go{
splash.args.url,
headers=splash.args.headers,
http_method=splash.args.http_method,
body=splash.args.body,
})
assert(splash:wait(0.5))
local get_dimensions = splash:jsfunc([[
function() {
var rect = document.querySelector('a[aria-label="Download XML"]').getClientRects()[0];
return {"x": rect.left, "y": rect.top}
}
]])
splash:set_viewport_full()
splash:wait(0.1)
local dimensions = get_dimensions()
-- FIXME: button must be inside a viewport
splash:mouse_click(dimensions.x, dimensions.y)
splash:wait(0.1)
return splash:html()
end
我的請求對象:
yield SplashFormRequest(self.urls['url'],
formdata=FormBuilder.build_form(response, some_object[0]),
callback=self.parse_cuenta,
cache_args=['lua_source'],
endpoint='execute',
args={'lua_source': self.script_click_xml})
在此先感謝
嗨@delpo,你有解決方案嗎? –
嘿@SanoopPK,我還沒有解決 – delpo