Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mistval/match-tags
Extract an HTML element and its children from a string
https://github.com/mistval/match-tags
Last synced: 16 days ago
JSON representation
Extract an HTML element and its children from a string
- Host: GitHub
- URL: https://github.com/mistval/match-tags
- Owner: mistval
- License: mit
- Created: 2018-10-28T05:22:47.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-01-19T09:58:06.000Z (almost 6 years ago)
- Last Synced: 2024-09-22T20:10:06.473Z (about 2 months ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# match-tags
Extract an HTML element and its children from a string. This can make it more efficient to work with HTML parsing libraries like cheerio. You can use this module to extract only the part of the page you care about, and have the parsing library parse only that.
## Usage
```js
const extract = require('match-tags');const html = `
Navigate
`;console.log(extract(html, '
'));
```This outputs the following:
```
Navigate
```You can also pass a third argument to the extract function, an index to begin the search from.
## About
I use this for a couple of specific applications, so it's not necessarily tested in corner cases and with bad markup. If it's not working how you expect, feel free to open an issue in the GitHub repo.