python - Scrapy Splash 结果为 504
问题描述
我正在尝试在一个特定酒店的页面上获取未来 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。但是如果你想看更多完整的代码在这里:-)
当然希望你比我聪明(我想我已经知道答案了)。
解决方案
有时网络会阻止用户ip
,尝试使用不同proxy servers
的,因为它可以通过我的系统访问。
推荐阅读
- python - 我如何将用户发送到新的“块”而不是继续相同的路径?
- python - 如何修复错误 Python Selenium Chromdriver 中不可交互的元素
- hadoop - 如何使用“WARN HadoopFileSystemOwner: found no group information for myname (auth:SIMPLE)”停止 hadoop 垃圾邮件日志
- python - 如何用另一个数据框行重命名列名?
- ruby - 使用默认值的rails嵌套哈希
- java - Java 8 - 可选
在 CustomizedObject 中获取列表的第一个元素 - java - Java - 如何从运行 Java 程序的主命令行获取输入?
- java - 找不到合适的驱动程序雪花 JDBC
- ios - 如何在 Xamarin.Forms ios 中更改工具栏图标颜色
- javascript - 更改模态窗口