evaljs即使不应该返回nil?

问题描述 投票:1回答:1

以下代码......

splash:evaljs('document.querySelectorAll("iframe.iframe-container.js-oddset-game-iframe")[0].contentDocument.querySelectorAll("td.leftText a.eventLink").length')

...返回8 - 即阵列中有8个节点。

但是,当我尝试直接返回nodeList(数组)时,结果为nil?显然应该返回一个表,因为从javascript代码返回一个数组。

这是Splash中的错误吗?无法通过Splash处理对iframe中元素的访问权限?我也有--js-cross-domain-access选项。

scrapy splash
1个回答
0
投票

这不是一个bug。 iframe只有在render.json端点与iframes=1参数一起使用时才可用。使用它时,无法运行自定义Lua脚本。

请参阅文档:https://splash.readthedocs.io/en/stable/api.html#render-json

这个答案:https://stackoverflow.com/a/44682917/4082726

© www.soinside.com 2019 - 2024. All rights reserved.