Wicked Good XPath
x refers to the Google SVN revision when
wgxpath.install.js was built;
y refers to any improvements to this package.
I'm pretty lazy, so I didn't build Wicked Good XPath myself. When the pre-compiled wgxpath.install.js is updated, I'll update this package.
Install with npm:
npm install wgxpath
Make sure things are working:
This example scrapes the Merriam-Webster Word of the Day. This code can also be found in
var wgxpath = require'wgxpath';var jsdom = require'jsdom';var url = '';var expressionString = '//*[@id="content"]/div/ul/li/strong';jsdomenvhtml: urlwgxpathinstallwindow;var expression = windowdocumentcreateExpressionexpressionString;var result = expressionevaluatewindowdocumentwgxpathXPathResultTypeSTRING_TYPE;console.log'The Word of the Day is "' + resultstringValue + '."';;