0.1.3 • Published 6 years ago

padex v0.1.3

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

Padex

Get response of some urls among linked pages

npm: padex CircleCI Coverage Status tested with jest code style: prettier license: mit TypeScript

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[],
	// }
})();