我只想使用splash脚本并返回职位列表的urls

我正在使用scrapy和splash来爬取this 网站,尽管我知道我可以爬取它的API,但出于某些原因,我仍然使用splash和scrapy。我的问题是,我只想让我的lua脚本返回职位列表的urls而不是整个splash:html()页面,我一直在尝试这样做,但是我得到了下面这个错误消息:

 {
    "error": 400,
    "description": "执行Lua脚本时发生错误",
    "type": "ScriptError",
    "info": {
        "message": "Lua错误:/app/splash/lua_modules/libs/treat.lua:45:不能更改受保护的metatable",
        "type": "LUA_ERROR"
    }
}

我一直在使用的lua脚本也显示在下面:-

function main(splash, args)
    assert(splash:go(args.url))
    splash:wait(5.0)
    local treat = require('treat')
    listings = assert(splash:select_all("ul.job_listings > li> a"))

    return {
       listing_urls = treat.as_array(listings)
    }

end
点赞
用户2858170
用户2858170
函数 `treat.as_array(tbl)` 试图更改其参数的元表。

错误是由于 `listings` 的元表设置了 `__metatable` 字段。

来自 [https://www.lua.org/manual/5.3/manual.html#pdf-setmetatable](https://www.lua.org/manual/5.3/manual.html#pdf-setmetatable):

> 如果原始元表有一个 `__metatable` 字段,会引发错误。
2020-05-26 15:29:38