https://github.com/mikeal/webtouch
Validate that a web site and all its required resources are available.
https://github.com/mikeal/webtouch
Last synced: 2 months ago
JSON representation
Validate that a web site and all its required resources are available.
- Host: GitHub
- URL: https://github.com/mikeal/webtouch
- Owner: mikeal
- Created: 2013-07-13T17:06:52.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2017-07-11T22:06:06.000Z (almost 8 years ago)
- Last Synced: 2024-04-14T05:52:04.521Z (about 1 year ago)
- Language: JavaScript
- Size: 17.6 KB
- Stars: 20
- Watchers: 6
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
### webtouch
`npm install webtouch`
Validate that a web site and all its required resources are available.
```javascript
var webtouch = require('webtouch')webtouch('http://www.google.com', function (e, urls) {
if (e) throw e
console.log(urls)
})
```The website will be parsed and all the resources in the html will be touched via an HTTP GET.
There's also an event emitter returned that you can use to monitor.
```javascript
webtouch('http://www.google.com').on('get', function (url) {console.log("fetching", url)})
```#### webtouch(urls, [opts], cb)
* **`urls`** Either a string for a single url or an array of urls.
* **`opts`**
* **`timeout`** A timeout in millisecond for each GET, this is *not* a timeout for the entire crawl.
* **`img`** Fetch images, defaults to `true`.
* **`meta`** Fetch images in meta tags where `itemprop === "image"`, defaults to `true`.
* **`script`** Fetch scripts, defaults to true.
* **`a`** Fetch and parse links, defaults to `false`. This method is dangerous since it basically turns webtouch in to a crawler that could potentially never return.
* **`cb`** `function (error, urls) {}` returns all of the urls that have been touched.##### events
* *`get`* `function (url){}` The url that is about to be touched.
* *`resp`* `function (response, url){}` The http.ClientResponse object and url that was just touched.