Latest Threat Research:Malicious dYdX Packages Published to npm and PyPI After Maintainer Compromise.Details
Socket
Book a DemoInstallSign in
Socket

draper

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

draper

DOM extraction expression evaluator.

Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

Surgeon

Travis build status Coveralls NPM version Canonical Code Style Twitter Follow

Declarative DOM extraction expression evaluator.

Powerful, succinct, declarative API.

articles:
- select article
- body:
  - select .body
  - extract property innerHTML
  imageUrl:
  - select img
  - extract attribute src
  summary:
  - select .body p:first-child
  - extract property innerHTML
  - format text
  title:
  - select .title
  - extract property textContent
pageName:
- select .body
- extract property innerHTML

Have you got suggestions for improvement? I am all ears.

Error handling

Surgeon throws the following errors to indicate a predictable error state. Use instanceof operator to determine the error type.

Note:

Surgeon errors are non-recoverable, i.e. a selector cannot proceed if it encounters an error. This design ensures that your selectors are capturing the expected data.

If a selector breaks, adjust the select query to increase selector specificity, adjust filter and/or validation criteria.

NameDescription
NotFoundErrorThrown when an attempt is made to retrieve a non-existent attribute or property.
UnexpectedResultCountErrorThrown when a select action quantifier is not satisfied.
InvalidDataErrorThrown when a resulting data does not pass the validation.
SurgeonErrorA generic error. All other Surgeon errors extend from SurgeonError.

Example:

import {
  InvalidDataError
} from 'surgeon';

const subject = `
  <div class="foo">bar</div>
`;

try {
  x([
    'select .foo',
    'test /baz/'
  ], subject);
} catch (error) {
  if (error instanceof InvalidDataError) {
    // Handle data validation error.
  } else {
    throw error;
  }
}

Debugging

Surgeon is using debug to log debugging information.

Export DEBUG=surgeon:* environment variable to enable Surgeon debug log.

Keywords

dom

FAQs

Package last updated on 30 Jan 2017

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