Linkquest
Linkquest is an easy way to get all of the valid and invalid links on a single page or an entire site.
Install
To install Linkquest, simply use:
$ npm install linkquest
Usage
Note: There have been major changes in how Linkquest works in v1.0.0. If you are looking for the old functionality, you might be looking for linkquest-cli.
To use Linkquest in your project, simply create a new instance of it passing the url of the site to gather links from and then calling the start method:
const Linkquest = ; const linkquest = 'https://example.com'; await linkqueststart;
The options that can be passed to a new instance of linkquest are as follows:
param | type | description | default |
---|---|---|---|
options | Object | {} | |
options.browser | puppeteer.Browser | If you are already using puppeteer you can pass the browser instance so it gets reused | null |
options.page | puppeteer.Page | If you are already using puppeteer you can pass the page instance so it gets reused | null |
noFollow | boolean | If set to true, linkquest will not check the entire host and just the url provided | false |
API
start
Starts the crawling of the host or url for links. Note that this is an async method.
example:
const Linkquest = ; const linkquest = 'https://example.com'; await linkqueststart;
register
Linkquest supports a plugin infrastructure that allows you to hook into each page that's processed by Linkquest and complete a task. The register method registers a linkquest-plugin with linkquest so it can be used.
param | type | description | default |
---|---|---|---|
plugin | Plugin | The plugin to register | |
options | Object | The options to pass to the plugin. See the documentation on the plugin's page for what options are available. |
Example
Below is an example of registering the linquest-screenshot
plugin:
const linkquest = 'http://example.com/' silent: true ; linkquest; await linkqueststart;
Signals
Linkquest offers the ability to respond to certain events using signals.
The following signals are dispatched by Linkquest:
onNavigateToLink
This signal is dispatched when a link is navigated to.
This data contained in this signal is the url that was navigated to and whether or not it is a valid link.
example:
const linkquest = 'http://example.com/'; linkquestonNavigateToLink; await linkqueststart;
onLinksGathered
This signal is dispatched when all of the links on a page are gathered.
The data contained in this signal is the page that the links were gathered from and an array of the links that have been gathered from that page.
example:
const linkquest = 'http://example.com/'; linkquestonLinksGathered; await linkqueststart;
onComplete
This signal is dispatched when Linkquest is done gathering links.
The data contained in this signal is the list of valid and invalid urls.
example:
const linkquest = 'http://example.com/'; linkquestonComplete; await linkqueststart;
Tests
To run the tests available for Linkquest, use:
$ npm run test
License
MIT