# scrake

> Like cheerio, but with the beefed-up jsdom and an opinionated default options that can go wildly wrong (just like the chainsaw man in Killing Floor)

Latest version **0.1.2** (published 2017-12-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install scrake
pnpm add scrake
yarn add scrake
bun add scrake
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2017-12-20 |
| First published | 2017-12-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Steve Fan |
| Maintainers | stevefan1999 |
| Keywords | DOM |

## Links

- npm: https://www.npmjs.com/package/scrake
- Repository: https://github.com/stevefan1999/scrake
- Issues: https://github.com/stevefan1999/scrake/issues
- npm.io page: https://npm.io/package/scrake

## Dependencies (2)

- [jsdom](https://npm.io/package/jsdom.md) ^11.5.1
- [jquery](https://npm.io/package/jquery.md) ^3.2.1

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 0.1.2 (latest) — 2017-12-20
- 0.1.1 — 2017-12-20
- 0.0.9 — 2017-12-18
- 0.0.8 — 2017-12-18
- 0.0.1 — 2017-12-18

## README

# scrake

A simple and dangerous wrapper based upon [@tmpvar/jsdom](https://github.com/tmpvar/jsdom) that tries to emulate a lightweight and headless (and limited) browser environment for testing/web scraping.

Inspired by [@cheeriojs/cheerio](https://github.com/cheeriojs/cheerio) and [@ariya/phantomjs](https://github.com/ariya/phantomjs/), but not restricted to only jQuery, and it does not feature a fully-fledged browser environment.

# ⚠️WARNING⚠️
By default, `scrake` will execute all possible resources & scripts to emulate a browser environment as much as possible. Although the actual execution is ran in a different V8 VM context, that still means `scrake`/jsdom is subject to XSS attack. Malicious users can use this to gain advantage to your Node environment, hence the `dangerous` in `simple and dangerous`

In other word, Use `scrake` at your own risk.

# Installation
```bash
$ npm install scrake --save <ENTER>
```
or
```bash
$ yarn add scrake <ENTER>
```

# Usage
```js
const scrake = require('scrake')

scrake({ html: '<h2 class="title">Hello world</h2>' }).then(domProps => {
  // domProps === { virtualConsole, cookie, dom, window, document, $ }
})

// if you prefer ES2015:
import scrake from 'scrake'

(async () => {
  let domProps = await scrake({ html: '<h2 class="title">Hello world</h2>' })
  const { virtualConsole, cookie, dom, window, document, $ } = domProps
})()
```
```js
scrake({ /* html: '', file: '', url: '' */ }, { /* extra options to supply to jsdom */ })
```

Arguments are passed via object initializer.

One and only one of the major operation argument type could be used, i.e. one of 'html', 'file' and 'url' must be specified and they are mutually exclusive.

Extra options are not validated, and the object is deconstructed and merged after the default options

# Known issue

jsdom is generally slower than cheerio, because jsdom is strictly parsing HTML that it has complicated validations. cheerio asserted it has 8x more the performance of jsdom <sup>[1]</sup>.

Fragment is not supported yet, since it does not have a valid jsdom props behind (it is however backed by a shared singleton <sup>[2]</sup> <sup>[3]</sup>)

I still can't get _http://www.google.com_ to work, It tells me a semi-colon is unexpected. I don't know why, probably because of encoding.

[1]: (https://github.com/cheeriojs/cheerio#features)
[2]: (https://github.com/tmpvar/jsdom/blob/master/lib/api.js#L35)
[3]: (https://github.com/tmpvar/jsdom/blob/master/lib/api.js#L126-L134)

---
_Source: https://npm.io/package/scrake · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
