splash:select
使用如何选择一个元素后,如何选择在它下面找到的所有作为子元素的锚元素?
我已经lua
用scrapy/splash尝试了这个脚本:
function main(splash)
assert(splash:go(splash.args.url))
assert(splash:wait(0.9))
local classlist = splash:select('.class-list')
local alinks = classlist:select_all('a')
return {alinks=alinks}
end
但我收到以下错误请求 Splash 错误:
{
u'info':{
u'line_number':12,
u'message': u'Lua error:[
string "..."
]:12:attempt to call method \'select_all\' (a nil value)',
u'type':u'LUA_ERROR',
u'source':u' [
string "..."
] ', u' error':u"attempt to call method 'select_all' (a nil value)"
},
u'type':u'ScriptError',
u'description':u'Error happened while executing Lua script',
u'error':400
}
我已经确认splash:select('.class-list')
返回一个有效的元素对象。