问题描述
目标:使用Node.js访问网页,使用xpath语法操作DOM并打印新的DOM。
Goal: Use Node.js to access a web page, manipulate the DOM using xpath syntax, and print the new DOM.
libxmljs可以,但是它具有NPM无法解决的几个依赖项。您使用哪些库对任意HTML进行xpath?
libxmljs is okay, but it has several dependencies which NPM doesn't resolve. Which libraries do you use to xpath arbitrary HTML?
推荐答案
我在Mac OS X上开发了libxmljs,所以这不应该是您的重大障碍。您需要 libxml2
库和 scons
实用程序才能成功构建。两者都可以通过macports或自制软件获得。有了libxml2后,请确保xml2-config命令行实用程序在您的路径中。这就是我用来获取适当的构建标志的方法。
I develop libxmljs on Mac OS X, so this shouldn't be your major hurdle. You need the libxml2
library and the scons
utility in order to build successfully. Both of these are available via macports or homebrew. Once you have libxml2, make sure the xml2-config command-line utility is in your path. That's what I use to get the appropriate build flags.
@mcandre我相信您是向github存储库提交票证的同一个人。希望您一切顺利。如果不是,请提供有关您的问题的更多信息。
@mcandre I believe you're the same person who submitted a ticket to the github repo. I hope you've gotten things worked out. If not, give more info about your problem. https://github.com/polotek/libxmljs
:马可(Marco)
这篇关于libxmljs的替代品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!