Lua脚本:URL:https://sustainabledevelopment.un.org/globalsdreport/2019#media
function main(splash, args)
splash.resource_timeout = 90
splash.images_enabled = false
assert(splash:go(args.url))
return {html=splash:html(),
png=splash:png(),
url=splash:url()
}
end
在splash窗口运行,得到以下error:
HTTP Error 400 (Bad Request)
Type: ScriptError -> LUA_ERROR
Error happened while executing Lua script
Lua error: [string "function main(splash, args) ..."]:4: network1
{
"error": 400,
"type": "ScriptError",
"description": "Error happened while executing Lua script",
"info": {
"source": "[string \"function main(splash, args)\r...\"]",
"line_number": 4,
"error": "network1",
"type": "LUA_ERROR",
"message": "Lua error: [string \"function main(splash, args)\r...\"]:4: network1"
}
}
看了很多帖子,没找到解决方法,最后通过这个issue找到了灵感,Webkit error 的问题可以参考这个。
把assert()删除后,成功把问题解决。
改后的脚本是这样的:
function main(splash, args)
splash.resource_timeout = 90
splash.images_enabled = false
splash:go(args.url)
return {html=splash:html(),
png=splash:png(),
url=splash:url()
}
end
解决原因:目前还不知道为什么,看400 networkerror1似乎是拒绝连接,但是不知道为什么去掉assert又可以了。留后面找到原因再解释。