# ctx-links

> 获取文件中的所有链接

Latest version **1.0.2** (published 2017-03-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install ctx-links
pnpm add ctx-links
yarn add ctx-links
bun add ctx-links
```

## 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.2 |
| Published | 2017-03-12 |
| First published | 2017-03-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | laomu1988@qq.com |
| Maintainers | laomu |
| Keywords | html-link, link, href |

## Links

- npm: https://www.npmjs.com/package/ctx-links
- Repository: https://github.com/laomu1988/get-links
- Homepage: https://github.com/laomu1988/get-links#readme
- Issues: https://github.com/laomu1988/get-links/issues
- npm.io page: https://npm.io/package/ctx-links

## Dependencies (1)

- [cheerio](https://npm.io/package/cheerio.md) ^0.22.0

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2017-03-12
- 1.0.1 — 2017-03-10

## README

# 获取文件中的所有链接

## install
```sh
npm install ctx-links
```

## usage
```js
var getLinks = require('ctx-links')
var src = `
<img src="/test.png">
<a href="/index.html">test</a>
<link href="../test.css">
<script src="test.js"></script>
`
var links = getLinks.html(src, 'http://www.test.com/test/index.html')
console.log(links)

/* 将输出
[ 'http://www.test.com/test.png',
  'http://www.test.com/index.html',
  'http://www.test.com/test.css',
  'http://www.test.com/test/test.js' ]
*/
```
## api
* html(html, baseUrl)
  - @param {string} html html内容
  - @param {string} baseUrl 网址
  - @return {array} 所有的链接地址（去重后的）
* css(cssContent, baseUrl) 取出css文件内部中的引用地址

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