Html 使用css选择器查找节点:查询

Html 使用css选择器查找节点:查询,html,css,lisp,common-lisp,Html,Css,Lisp,Common Lisp,我无法让css选择器:query正常工作。 完全不明白args是什么,以什么顺序排列的。 查看源代码: (defun query (inp &optional (trees buildnode:*document*)) "Given a css selector, attempt to find the matching nodes in the passed in dom-trees (defaults to the document)" (%query inp tre

我无法让
css选择器:query
正常工作。 完全不明白args是什么,以什么顺序排列的。

查看源代码:

(defun query (inp &optional (trees buildnode:*document*))
  "Given a css selector, attempt to find the matching nodes in the passed in
   dom-trees (defaults to the document)"
  (%query inp trees))
我不知道inp
inp
代表什么,但通过消除过程,假设它是指css选择器字符串

(defun get-page (url)
  "Get STP(DOM alternative) representation of page"
  (chtml:parse
   (drakma:http-request url)
   (cxml-stp:make-builder)))

(css-selectors:query "a" (get-page "http://lisp.org/")) ; Doesn't work
(css-selectors:query (get-page "http://lisp.org/") "a") ; Worth a try

示例用法将非常有用。

编辑:Quickload
css选择器stp
以使其与stp一起工作

我联系了作者,文档已经更清楚了。对STP的支持应该已经合并并完成,但是作者为DOM编写了这个包,并且从未使用过STP。因此,它应该适用于STP,但无论出于何种原因,它都不起作用

以下工作:

(defun get-page (url)
  "Get DOM representation of page"
  (chtml:parse
   (drakma:http-request url)
   (cxml-dom:make-dom-builder)))

(css-selectors:query "a" (get-page "http://lisp.org/")) ; Success!

编辑:Quickload
css选择器stp
以使其与stp一起工作

我联系了作者,文档已经更清楚了。对STP的支持应该已经合并并完成,但是作者为DOM编写了这个包,并且从未使用过STP。因此,它应该适用于STP,但无论出于何种原因,它都不起作用

以下工作:

(defun get-page (url)
  "Get DOM representation of page"
  (chtml:parse
   (drakma:http-request url)
   (cxml-dom:make-dom-builder)))

(css-selectors:query "a" (get-page "http://lisp.org/")) ; Success!