Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

html-a

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

html-a

Parse HTML and extract «a» elements

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

html-a

npm version Build Status bitHound Overall Score Coverage Status

Node.js module. Parse HTML and extract «a» elements.

Features

  • Nothing extra.
  • Fast and simple.
  • Small size (not bloated).
  • Only using the fast htmlparser2.

Install

$ npm install --save html-a

Usage

HTML string example:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Example HTML</title>
</head>
<body>
    <p id="first">
        <a href="http://site.com"><b>Some site</b></a>
    </p>
    <p>
        <a href="#first">Link in page</a>
        <a href="javascript:alert('Hello, World!');">Hello!</a>
        <a href="/foo/bar">FooBar</a>
    </p>
</body>
</html>

CommonJS example:

const htmla = require ( 'html-a' );
const html = 'an example HTML is given above';

// Get href and innerHTML from «a» elements.
// For more information, use the options.
htmla ( html );
//=>
// [
//   { innerHTML: '<b>Some site</b>', href: 'http://site.com' },
//   { innerHTML: 'Link in page', href: '#first' },
//   { innerHTML: 'Hello!', href: 'javascript:alert(\'Hello, World!\');' },
//   { innerHTML: 'FooBar', href: '/foo/bar' }
// ]


// OR just get all DOM «a» elements
htmla.getElements ( html );

API

htmla ( html, [options] )

Gets custom info about «a» elements.
Returns an Array.

html

Type: string

HTML string for extract «a» elements.

options

Type: object

Settings to obtain the desired information.

text

Type: boolean
Default: false

Gets inner text in element.

innerHTML

Type: boolean
Default: true

Gets inner HTML in element.

href

Type: boolean
Default: true

Gets attribute href in element.

attributes

Type: boolean
Default: false

Gets all attributes in element.

element

Type: boolean
Default: false

Gets element DOM object.

htmla.getElements ( html )

Parses HTML, gets all DOM «a» elements.
Returns an Array.

html

Type: string

HTML string for extract «a» elements.

License

MIT © Nikita «Arttse» Bystrov

Sponsor

Keywords

FAQs

Package last updated on 29 Sep 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

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