我想运行一个启动脚本,它在lua中做一些事情,然后将结果返回给我的scrapy机器人。但是,我只能接收html主体,而不能接收return语句中的任何变量。
splash:go(...)
--lua/splash stuff
test = 500
return {
-- another SO thread stated that these have to be in JSON format? doesn't work either way though
test = test
}我尝试使用JSON-endpoint,但结果相同。Scrapy-Splash文档也没有真正解释如何获取这些变量。
所以我的问题是-如何通过scrapy_plash.SplashRequest调用从我的lua脚本接收任意返回变量?
这是我当前的启动请求:
yield SplashRequest(url, self.parse,
args={'lua_source': QuotesSpider.SPLASH_SCRIPT, 'wait': 0.5})发布于 2020-09-27 18:34:23
splashRequest的默认设置是render.html,它只返回html,不执行lua脚本。添加execute端点可以正确运行lua脚本,从而返回所需的变量
yield SplashRequest(url, self.parse,endpoint='execute'
args={'lua_source': QuotesSpider.SPLASH_SCRIPT, 'wait': 0.5})https://stackoverflow.com/questions/64078353
复制相似问题