0.1.3 • Published 6 years ago
padex v0.1.3
Padex
Get response of some urls among linked pages
Install
yarn add [-D] padex
Example
import * as url from 'url';
import {Padex} from 'padex';
const padex = new Padex('https://example.com', {
//# In the below, Default values.
//## Whether takes a urls from head tag of a got html
head: false,
//## Sleep time between request and next request
sleep: 400,
//## How many times to move
deep: 3,
//## Whether to allow requests for current url
// The following examines whether the URL passed to `Padex`
// and the `hostname` of the current URL are together.
validate: ({url: currentUrl, location}) => {
const currentLocation = url.parse(currentUrl);
return currentLocation.hostname === location.hostname;
}
})
(async () => {
const result = await padex.process();
// result === {
// url: 'https://example.com',
// options: {head, sleep, deep, validate},
// root: Document,
// documents: Document[],
// }
})();