Socket
Socket
Sign inDemoInstall

wgxpath

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wgxpath

Wicked Good XPath


Version published
Weekly downloads
47K
decreased by-9.49%
Maintainers
1
Weekly downloads
 
Created
Source

node-wgxpath

Wicked Good XPath is a fast implementation of document.createExpression and document.evaluate (DOM3-XPath) in pure Javascript.

Version

x.y.z: x.y refers to the Wicked Good XPath revision when wgxpath.install.js was built; z 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.

Installation

Install with npm:

npm install wgxpath

Make sure things are working:

node node_modules/wgxpath/word_of_the_day.js

Example

This example scrapes the Merriam-Webster Word of the Day. This code can also be found in word_of_the_day.js.

var wgxpath = require('wgxpath');
var jsdom = require('jsdom');

var url = 'http://www.merriam-webster.com/word-of-the-day/';
var expressionString = '//*[@id="content"]/div[3]/ul/li[1]/strong';

jsdom.env({
  html: url,
  done: function(errors, window) {
    wgxpath.install(window);
    var expression = window.document.createExpression(expressionString);
    var result = expression.evaluate(window.document,
        wgxpath.XPathResultType.STRING_TYPE);
    console.log('The Word of the Day is "' + result.stringValue + '."');
  }
});

Keywords

FAQs

Package last updated on 13 Apr 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc