如何解决飞溅:刮刮具有多个页面的网站的问题
我使用的是python 3.8和scrapy 1.6,我写了一个Spider来抓取非英语网站,但分页仅在启用javascript的情况下有效。因此,我使用了飞溅。现在,我的问题是,下一个按钮跳到了最后一页(在此页面的第62页),所以,我想我必须告诉飞溅来选择每个页码(而不是下一个按钮)。这是我写的启动代码:
function main(splash,args)
splash:set_user_agent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/84.0.4147.125 Safari/537.36")
splash.private_mode_enabled=false
assert(splash:go(args.url))
assert(splash:wait(1))
next_page=assert(splash:select_all(".c-pager__next:nth-child(1),nth-child(62)"))
next_page:mouse_click()
assert(splash:wait(5))
splash:set_viewport_full()
return {
html = splash:html()
}
end
现在,当我渲染它时,出现此错误:
{
"error": 400,"type": "ScriptError","description": "Error happened while executing Lua script","info": {
"source": "[string \"function main(splash,args)\r...\"]","line_number": 4,"error": "network3","type": "LUA_ERROR","message": "Lua error: [string \"function main(splash,args)\r...\"]:4: network3"
}
}
有人可以帮助我解决分页问题吗?
谢谢!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。