# pagelinks

> Get all links from a webpage

Latest version **3.0.1** (published 2021-11-28) · MIT license · 0 weekly downloads

## Install

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

Provides the command `pagelinks`.

## Health

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

Positive: no vulnerabilities; high maintenance score.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 3.0.1 |
| Published | 2021-11-28 |
| First published | 2014-05-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=14.18.1 |
| Dependencies | 3 |
| Unpacked size | 15.1 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Geir Gåsodden |
| Maintainers | zrrrzzt |
| Keywords | utility, screenscraping |

## Links

- npm: https://www.npmjs.com/package/pagelinks
- Repository: https://github.com/zrrrzzt/pagelinks
- Homepage: https://github.com/zrrrzzt/pagelinks#readme
- Issues: http://github.com/zrrrzzt/pagelinks/issues
- npm.io page: https://npm.io/package/pagelinks

## Dependencies (3)

- [cheerio](https://npm.io/package/cheerio.md) 1.0.0-rc.10
- [minimist](https://npm.io/package/minimist.md) 1.2.5
- [valid-url](https://npm.io/package/valid-url.md) 1.0.9

## Alternatives

- [lodash.assign](https://npm.io/package/lodash.assign.md) — 2.3M weekly downloads
- [lodash.chunk](https://npm.io/package/lodash.chunk.md) — 1.8M weekly downloads
- [react-native-ios-utilities](https://npm.io/package/react-native-ios-utilities.md) — 138.5K weekly downloads
- [@technically/lodash](https://npm.io/package/@technically/lodash.md) — 50.9K weekly downloads
- [@fluid-topics/ft-icon](https://npm.io/package/@fluid-topics/ft-icon.md) — 20.6K weekly downloads

## Recent versions

- 3.0.1 (latest) — 2021-11-28
- 3.0.0 — 2020-04-30
- 2.0.1 — 2016-08-28
- 2.0.0 — 2016-07-18
- 1.0.3 — 2015-01-11
- 1.0.2 — 2015-01-11
- 1.0.1 — 2015-01-10
- 1.0.0 — 2015-01-10
- 0.0.1 — 2014-05-29

## README

[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard)

# pagelinks 

Node.js module/CLI app for scraping links from a webpage

## Installation

```
$ npm install pagelinks
```

You can also install it globally to use the CLI version

```
$ npm install pagelinks -g
```

## Usage - module

Pass an object with the uri, file or data for the page you want to scrape.

```JavaScript
const pagelinks = require('pagelinks')
const options = {
  uri: 'http://www.google.com'
}

pagelinks(options, function(error, links) {
  if (error) {
    throw error
  }
  console.log(links)
})
```

or

```
const options = {
  file:'mypath/myfile.html'
}
```

or

```
const options = {
  data: <pagedata>
}
```

returns

```JavaScript
[
  {
    text: 'Søk',
    href: 'https://www.google.no/webhp?tab=ww',
    id: 'gb_1',
    class: 'gbzt gbz0l gbp1'
  },
  {
    text: 'Bilder',
    href: 'http://www.google.no/imghp?hl=no&tab=wi',
    id: 'gb_2',
    class: 'gbzt'
  },
  {
    text: 'Maps',
    href: 'http://maps.google.no/maps?hl=no&tab=wl',
    id: 'gb_8',
    class: 'gbzt'
  },
  {
    text: 'Play',
    href: 'https://play.google.com/?hl=no&tab=w8',
    id: 'gb_78',
    class: 'gbzt'
  },
  { text: 'Alt om Google', href: '/intl/no/about.html' },
  {
    text: 'Google.no',
    href: 'http://www.google.com/setprefdomain?prefdom=NO&prev=http://www.google.no/&sig=K_Yael_-8yUXfGhE8aXDXMo07ePOo%3D'
  }
]
```

Default the module will return text, 'href', 'id', 'target' and 'class' from the links.
For other attributes/properties supply an array of attributes.

```
const options = {
  uri:<uri>,
  attrs:['href', 'data-title', 'data-description']
}
```

## Usage - CLI

To use it as a CLI app install it globally.

To display help

```
$ pagelinks --help
```

To display version

```
$ pagelinks --version
```

Usage:

```
$ pagelinks <uri>
```

or

```
$ pagelinks --file=<file>
```

or

```
$ pagelinks --data=<data>
```

Default the module will return text, 'href', 'id', 'target' and 'class' from the links.
For other attributes/properties supply a comma separated string of attributes.

```
$ pagelinks <uri> --attrs='href,data-title,data-description'
```

## License

[MIT](LICENSE)

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