I'm using scrapy and Splash to crawl website. I want a perfect lua script that first click the drop down button and from there it must select the specific country name e.g (Morroco) from this site (https://lenovocareers.com/#search) and wait for a page to render the required contents(Jobs) for only that city(Morroco). my lua script I've tried so far is shown below but note that it not working at all.
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