【发布时间】:2019-05-31 05:16:00
【问题描述】:
我正在尝试从一家特定酒店的页面上获取未来 28 天的价格。我怀疑我被阻止了,但我不太确定。
我得到了一些结果,但不是全部。我什至尝试过使用各种用户代理,download_delay 为 30,启用 httpcahce 等。
这是我的 lua 脚本
function main(splash, args)
splash.private_mode_enabled = false
splash.js_enabled = true
splash.images_enabled = false
assert(splash:go(args.url))
function wait_for(splash, condition)
while not condition() do
splash:wait(20.0)
end
end
wait_for(splash, function()
return splash:evaljs("document.querySelector('ul.availability-table-revamp') != null")
end)
assert(splash:wait(30.0))
splash:set_viewport_full()
return {
html = splash:html(),
}
end
我正在抓取的页面是[这里][1]。
我如何确定是该页面阻止了我?酒店页面上没有政策 - 但(当然)引擎的主页上有政策......
我当然有更多的代码要展示,但我猜唯一能解决这个问题的就是 lua。但是如果你想看更多完整的代码是here :-)
当然希望你比我聪明(不过我想我已经知道答案了)。
【问题讨论】:
标签: python web-scraping lua scrapy scrapy-splash