JavaScript SDK for Mercury Web Parser API.
- get(url) ⇒
Promise.<Page> Get content of page
- getAll(url) ⇒
Promise.<PagesList> Get content of all pages
Kind: global class
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 |
Kind: static class of ErrorServerResponse
Constructor generates error instance
Returns: ErrorServerResponse - - current instance
| Param | Type | Default | Description |
|---|---|---|---|
| statusCode | number |
http status code | |
| statusText | string |
http status code text | |
| [message] | string | null |
null |
error details |
Kind: global class
See: https://mercury.postlight.com/web-parser/
SDK for mercury api
Get content of page
Kind: 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');
})();Get content of all pages
Kind: 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');
})();