【发布时间】:2020-07-06 05:27:45
【问题描述】:
我正在运行 ScrapySplash,并尝试将在 Lua 中创建的表传递给 Parse 方法。如果我尝试访问该表,则会收到类型错误消息:“SplashJsonResponse”对象不可下标。
我的 Lua 脚本如下:
script = '''
function main(splash, args)
assert(splash:go(args.url))
assert(splash:wait(0.5))
img = {}
for i=1,5 do
table.insert(img, "Testing")
end
return {
html = splash:html(),
png = splash:png(),
har = splash:har(),
img,
}
end
'''
那么我的解析方法就是:
def parse_item(self, response):
images = response['img']
print (images)
但是,如上所述,这只会在 images = response['img'] 行上给我一个错误,说 'SplashJsonResponse' object is not subscriptable'。
有人知道我如何在 parse 方法中访问这个 Lua 表中的值吗?
谢谢
【问题讨论】:
标签: python lua scrapy scrapy-splash