我很难让css-selectors:query工作。完全不明白什么args进入和按什么顺序。http://quickdocs.org/css-selectors/
查看源代码:
(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代表什么,但是通过消除的过程,假设它意味着一个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示例用法将有很大帮助。
发布于 2013-11-29 23:57:23
编辑:快速加载css-selectors-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!https://stackoverflow.com/questions/20258658
复制相似问题