WebSnifferJS
Simple HTML parser for convert HTML page to Object.
Install
npm install --save web-sniffer-js
Usage
- Download content
Page HTML
HomePagePage2RSS
- Parse functions
In order to parse an HTML page there are two functions at your disposal:
-
parseWithLink(url, callback)
- url: String -> Your Web page link;
- callback: function -> The function execute when parser will end.
Exemple:
const webSniffer = ;const sniffer = ;sniffer;
-
parseWithFile(HTMLPage, callback)
- HTMLPage: String -> Your Web page content;
- callback: function -> The function execute when parser will end.
Exemple:
const webSniffer = ;const sniffer = ;// HtmlContent is the page content.sniffer;
Return HTML Object
- Search function
To search for web content at a specific position there is the function :
-
search(stringSearch)
- stringSearch: String -> The search line.
Syntax of the search line.
balise 1 name | [balise 1 content 1, balise 1 content 2, ...] ; balise 2 name | [balise 2 content 1, balise 2 content 2, ...] | {number of occurrences (min = 0) }; ...
No 'number of occurrences' mean search the first by default.
Ex : "body;nav|[id="menu",class="test"];ul;li|{3}"
Go to the balise 'body' search in the first balise 'nav' with 'id' is 'menu' et 'class' is 'test' and go to 'ul' and return the content from the fouth 'li'.
Usage Exemple :
const webSniffer = ;const sniffer = ;sniffer;
Return HTML Object
Functions
Name | Available | Description |
---|---|---|
parseWithLink(link: string , callback: function ) : HtmlObject |
ALL | Parse HTML content from a link page |
parseWithFile(HtmlContent: string , callback: function ) : HtmlObject |
ALL | Parse HTML content |
search(stringSearch: string ) : HtmlObject |
ALL | Parse HTML content |