html-a
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:
Example HTML Some site Link in page Hello! FooBar
CommonJS example:
const htmla = ;const html = 'an example HTML is given above'; // Get href and innerHTML from «a» elements.// For more information, use the options.;//=>// [// { 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» elementshtmla;
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