# the-fool

> WEB site scraper in nightmare

Latest version **1.0.0** (published 2018-01-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install the-fool
pnpm add the-fool
yarn add the-fool
bun add the-fool
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2018-01-22 |
| First published | 2016-12-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | ito-p |
| Maintainers | ito-p |

## Links

- npm: https://www.npmjs.com/package/the-fool
- Repository: https://github.com/ito-p/the-fool
- Homepage: https://github.com/ito-p/the-fool#readme
- Issues: https://github.com/ito-p/the-fool/issues
- npm.io page: https://npm.io/package/the-fool

## Dependencies (1)

- [co](https://npm.io/package/co.md) ^4.5.4

## Recent versions

- 1.0.0 (latest) — 2018-01-22
- 0.0.8 — 2017-01-08
- 0.0.7 — 2016-12-31
- 0.0.6 — 2016-12-26
- 0.0.5 — 2016-12-26
- 0.0.4 — 2016-12-24
- 0.0.3 — 2016-12-24
- 0.0.2 — 2016-12-24
- 0.0.1 — 2016-12-24

## README

# The Fool

The Foolは、jsonを渡すとスクレイピングしてきてくれます。

## Breaking changes

### v1.0.0
- Nightmare.jsは外から注入して使うようになりました！

## スクレイピング
サイト内の情報を取得します。
### 用意するjson
```json
{
  "data": [
    ["goto", "https://www.google.co.jp/"],
    ["type", "form[action='/search']", "fool"],
    ["click", "form[action*='/search'] [type=submit]"],
    ["wait", "._NId h3 a"],
    ["snatch", "._NId h3 a", "innerText"]
  ]
}
```

### サンプルコード
```es6
import Nightmare from 'nightmare';

const data = {
  data: [
    ["goto", "https://www.google.co.jp/"],
    ["type", "form[action='/search']", "fool"],
    ["click", "form[action*='/search'] [type=submit]"],
    ["wait", "._NId h3 a"],
    ["snatch", "._NId h3 a", "innerText"]
  ]
};

const fool = new Fool(Nightmare({ show: true }));

fool.travel(data)
  .then(result => {
    console.log(result);
  });

/**
* CONSOLE
*
[ [ 'foolの意味 - 英和辞典 Weblio辞書',
    'FOOLの番長ブログ - アメーバブログ',
    'foolの意味・用例｜英辞郎 on the WEB：アルク',
    'foolの意味 - goo辞書 英和和英',
    'FooL',
    'FOOLとは (フールとは) [単語記事] - ニコニコ大百科',
    'フール(FOOL)｜ホットペッパービューティー',
    'FOOL THE PUBLIC OFFICIAL WEB SITE - Jimdo',
    'Shaqtin\' A Fool - NBA.com',
    'Fool.com: Stock Investing Advice | Stock Research' ] ]
*/
```

### その他の操作について

nightmare.jsを使用しています。下記は主なコマンドです。
Intaract with the pageの詳細は、nightmareをご参照ください。

https://github.com/segmentio/nightmare/blob/master/Readme.md#interact-with-the-page

|概要|intaract with the page|json.dataの例|
|---|---|---|
|WEBページを開く|goto|["goto", "https://www.google.co.jp/"]|
|テキストボックスに入力|type|["type", "form[action='/search']", "fool"]|
|セレクターで指定された<br>要素の表示を待つ|wait|["wait", "._NId h3 a"]|
|セレクターで指定された<br>要素をクリックする|click|["click", "form[action*='/search'] [type=submit]"]|
|セレクターで指定された<br>単一の要素のpropertyを取得する|scrape|["scrape", "._NId h3 a", "innerText"]|
|セレクターで指定された<br>要素のpropertyを配列で取得する|snatch|["snatch", "._NId h3 a", "innerText"]|

## 詩
> ゼロを知れ！いずれの遣り方も、無知であれば許される。 - アレイスター・クロウリー 『トートの書』(国書刊行会、1991年)

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