Mercury API SDK
JavaScript SDK for Mercury Web Parser API.Bages
Documentation
Classes
Functions
- get(url) ⇒
Promise.<Page>
Get content of page
- getAll(url) ⇒
Promise.<PagesList>
Get content of all pages
ErrorServerResponse
Kind: global class* [new ErrorServerResponse(statusCode, statusText, [message])](#new_ErrorServerResponse_new)
* [.module.exports](#ErrorServerResponse.module.exports)
* [new module.exports(statusCode, statusText, [message])](#new_ErrorServerResponse.module.exports_new)
new ErrorServerResponse(statusCode, statusText, message)
Custom error message for abstract server response| Param | Type | Default | Description | | --- | --- | --- | --- | | statusCode |
number
| | http status code |
| statusText | string
| | http status code text |
| message | string
\| null
| null
| error details |ErrorServerResponse.module.exports
Kind: static class ofErrorServerResponse
new module.exports(statusCode, statusText, message)
Constructor generates error instanceReturns:
ErrorServerResponse
- - current instance| Param | Type | Default | Description | | --- | --- | --- | --- | | statusCode |
number
| | http status code |
| statusText | string
| | http status code text |
| message | string
\| null
| null
| error details |MercuryWebParser
Kind: global classSee: https://mercury.postlight.com/web-parser/
new MercuryWebParser()
SDK for mercury apiget(url) ⇒ Promise.<Page>
Get content of pageKind: global function
Returns:
Promise.<Page>
- - single page| Param | Type | Description | | --- | --- | --- | | url |
string
| page url |Example (Get single page)
import MercuryWebParser from '@frontender-magazine/mercury-sdk';
(async () => {
const parser = new MercuryWebParser();
const page = await parser.get('http://alistapart.com/article/design-like-a-teacher');
})();
getAll(url) ⇒ Promise.<PagesList>
Get content of all pagesKind: global function
Returns:
Promise.<PagesList>
- - array of pages| Param | Type | Description | | --- | --- | --- | | url |
string
| page url |Example (Get all pages as array)
import MercuryWebParser from '@frontender-magazine/mercury-sdk';
(async () => {
const parser = new MercuryWebParser();
const pages = await parser.getAll('http://alistapart.com/article/design-like-a-teacher');
})();