我正在使用 scrapy 和 Splash 来抓取网站。我想要一个完美的 lua 脚本,首先单击下拉按钮,然后它必须从该站点(https://lenovocareers.com/#search )中选择特定的国家名称,例如(Morroco )并等待页面呈现仅该城市(摩洛哥)所需的内容(工作)。到目前为止我尝试过的我的 lua 脚本如下所示,但请注意它根本不起作用。
function main(splash, args)
assert(splash:go(args.url))
assert(splash:wait(0.5))
local search_buttton = splash:select("div.header-search")
search_buttton:mouse_click()
assert(splash:wait(1.5))
local drop_buttton = splash:select_all("#select2-job-filter-locations-container")[1]
drop_buttton:mouse_click()
assert(splash:wait(1.5))
local choose_buttton = splash:select("#select2-job-filter-locations-result-h0vd-Morroco")
choose_buttton:mouse_click()
assert(splash:wait(1.5))
splash:set_viewport_full()
return {
html = splash:html(),
png = splash:png(),
har = splash:har(),
}
end