# cheerio-soupselect

> Adds CSS selector support to htmlparser for scraping activities - port of soupselect (python)

Latest version **0.1.1** (published 2012-03-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install cheerio-soupselect
pnpm add cheerio-soupselect
yarn add cheerio-soupselect
bun add cheerio-soupselect
```

## 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.1 |
| Published | 2012-03-04 |
| First published | 2011-11-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.2.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Matt Mueller |
| Maintainers | mattmueller |

## Links

- npm: https://www.npmjs.com/package/cheerio-soupselect
- npm.io page: https://npm.io/package/cheerio-soupselect

## Dependencies (1)

- [htmlparser2](https://npm.io/package/htmlparser2.md) 2.x

## Recent versions

- 0.1.1 (latest) — 2012-03-04
- 0.1.0 — 2012-01-17
- 0.0.3 — 2011-12-19
- 0.0.2 — 2011-11-26
- 0.0.1 — 2011-11-26

## README

# cheerio-soupselect

A fork of harryf's [node-soupselect]
(http://github.com/harryf/node-soupselect),
which is originally a port of Simon Willison's
[soupselect](http://code.google.com/p/soupselect/)
for use with node.js and node-htmlparser.

## Installation

    $ npm install cheerio-soupselect

## Testing

From the root folder:

    $ make test

## Features

### Selectors

cheerio-soupselect supports all of the most common jQuery
selectors, including multiple attribute selectors and
multiple selectors.

### Filters

soupselect also supports a bunch of basic filters, listed below.
Each filter is implement according to the jQuery specification.

* contains
* empty
* parent
* has
* header
* not
* eq
* gt
* lt
* even
* odd
* first
* last

### Filter Extensions

cheerio-soupselect supports custom filters through the
exported `filters` object. It's simple:

    var soupselect = require("cheerio-soupselect"),
        filters = soupselect.filters;
    ...
    filters["custom-filter"] = function(ctx, val){
        console.log("Hello filters!");
        return [];
    };
    ...
    var ret = soupselect.select(dom, ":custom-filter('awesome arg')");

The `ctx` parameter provides an array of `htmlparser2`
DOMs, which are themselves arrays. These element are
grouped by parent.

The `val` parameter provides access to everything inside
the brackets of the filter, if anything.

A few notes about custom selectors:

* Your custom function **must** return an array.

* For the most part, you will not need to handle
nesting filters/selectors. However, if you wish
to modify the nested selector then, you may do
so by modifiying `val`.

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