# scrape-url

> Scrape URL with CSS selectors

Latest version **4.0.1** (published 2025-04-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install scrape-url
pnpm add scrape-url
yarn add scrape-url
bun add scrape-url
```

## Health

**Score 50/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; has provenance.

Warnings: low downloads.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 4.0.1 |
| Published | 2025-04-23 |
| First published | 2013-10-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 5.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 2 |
| Author | matthewh |
| Maintainers | matthewh |
| Keywords | scrape, scraping, url, web |

## Links

- npm: https://www.npmjs.com/package/scrape-url
- Repository: https://github.com/MatthewSH/npm-packages
- Issues: https://github.com/MatthewSH/npm-packages/issues
- npm.io page: https://npm.io/package/scrape-url

## Dependencies (2)

- [wretch](https://npm.io/package/wretch.md) 2.11.0
- [cheerio](https://npm.io/package/cheerio.md) ^1.0.0

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 4.0.1 (latest) — 2025-04-23
- 4.0.0 — 2025-04-23
- 3.0.0 — 2016-04-22
- 0.0.1-security — 2016-03-23
- 2.0.0 — 2016-03-22
- 1.0.3 — 2014-04-11
- 1.0.2 — 2014-03-03
- 1.0.1 — 2014-02-09
- 1.0.0 — 2014-02-07
- 0.0.3 — 2014-02-07
- 0.0.2 — 2014-02-07
- 0.0.1 — 2013-10-14
- 0.0.0 — 2013-10-14

## README

# scrape-url

Scrape URLs with CSS selectors and return elements.

## Usage

**Basic Usage**

```javascript
var scrape = require("scrape-url");

scrape("http://www.google.com/", "a", function (error, links) {
  if (error) {
    throw new Error(error);
  }
  links.forEach(function (element, index) {
    console.log(index + 1 + ". " + element.text());
  });
});
```

You can also pass through an array of selectors.

```javascript
scrape(
  "http://www.google.com/",
  ["a", "p"],
  function (error, links, paragraphs) {
    //
  }
);
```

Instead of a string URL, you can pass through options if you so wish.

```javascript
var options = {
  url: "http://google.com",
  headers: {
    "user-agent": "SoCool 2.0"
  }
};

scrape(options, 'p', ...);
```

**Sending Post Requests**

Along with the normal `get` request scraping, you can also send post requests.

```javascript
var options = {
  url: "http://suchwow.com/form.php",
  form: {
    message: "Whoa, such a form.",
  },
};

scrape.post(options, ["body .response"], function (error, content) {
  //
});
```

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