我可以使用 > KRL query() 选择器中的运算符?
我想使用 KRL query() 获取嵌套的 DIV 标签,但它抱怨
ERROR Rules.pm a8x40 show_xfers Ruleset a8x40 failed: html.query error - Invalid specification ">div" in query: div.recent-transfer>div
Here's the HTMLfragment (文件中有多个):
<div class='recent-transfer'>
<span>...</span>
<div> <!-- * * * -->
<div>...</div>
<div>...</div>
</div>
</div>
Here's my function:
recent = function() {
t = http:get(the_url).pick("$..content");
t.query("div.recent-transfer>div")
}
I Want to select the DIV MARKED * * *
。我是否需要链接多个 query() 语句才能获取 DIV?
I want to get a nested DIV tag using KRL query() but it complains with
ERROR Rules.pm a8x40 show_xfers Ruleset a8x40 failed: html.query error - Invalid specification ">div" in query: div.recent-transfer>div
Here's the HTML fragment (there are multiple in the file):
<div class='recent-transfer'>
<span>...</span>
<div> <!-- * * * -->
<div>...</div>
<div>...</div>
</div>
</div>
Here's my function:
recent = function() {
t = http:get(the_url).pick("$..content");
t.query("div.recent-transfer>div")
}
I want to select the DIV marked * * *
. Do I need to chain several query() statements to get the DIV?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当我尝试重现您的问题时,我没有收到相同的错误。相反,我会得到“NOT_FOUND_ERR: DOM Exception 8”。就我而言,这根本不是选择器的问题;而是选择器的问题。事实上,t.query 的返回值是一个数组。如果我想在
notify()
中使用它,我必须从数组中取出第 0 个元素并返回它。我不知道你是否也遇到同样的问题。但这里有一个适合我的示例规则集:
When I tried to reproduce your problem, I didn't get the same error. Instead, I would get a "NOT_FOUND_ERR: DOM Exception 8". In my case, it wasn't a problem with the selector at all; it was the fact that the return value of
t.query
was an array. If I wanted to use that in, say, anotify()
, I had to get the 0th element out of the array and return that instead.I don't know if that is the same problem you are having. But here's a sample ruleset that works for me:
"div.recent-transfer>div"
是一个有效的查询。 KNS 出现问题,导致间歇性故障。以下是该函数的使用方式,这样返回的数组就不会出现问题:
"div.recent-transfer>div"
is a valid query. There was a problem in the KNS causing intermittent failures.Here's how the function is used, such that the returned array doesn't make problems: