check-url
Check a remote URL's HTTP response.
Why?
Because you want a poorly written link checker.
Installation:
$ npm i check-url -S
API:
{...}
Usage:
const checkUrl = ; ;
Output:
In some cases, a server may not respond to a method=HEAD
request, so you can override the request method by passing the optional second parameter, method
, as seen in the following example:
const checkUrl = ; ; /* OUTPUT:{ __method: 'HEAD', contentType: 'text/html;charset=UTF-8', ok: false, origUrl: 'https://www.wellsfargo.com', status: 400, statusText: 'Bad request', url: 'https://www.wellsfargo.com' }*/ ; /* OUTPUT{ __method: 'GET', contentType: 'text/html;charset=UTF-8', ok: true, origUrl: 'https://www.wellsfargo.com', status: 200, statusText: 'OK', url: 'https://www.wellsfargo.com' }*/
Similarly, if you want the promise to pass you back some data, you can pass an optional third parameter, data
, which will be merged into the response:
const checkUrl = ; ; /* OUTPUT:{ _id: '__LATIMES', contentType: 'text/html;charset=UTF-8', ok: true, origUrl: 'http://latimes.com', status: 200, statusText: 'OK', url: 'http://www.latimes.com/' }*/
Or, if you're trying to process obscenely large lists of URLs, you may need to throttle yourself, before you wreck yourself:
const checkUrl = ; const Queue = ;const tippyTopSites = ; const queue = 10; tippyTopSites;