extract-hrefs
v1.0.4
Published
This library is used to extract hrefs from a given HTML string.
Maintainers
Readme
Extract Hrefs
This library provides a simple way to extract href attributes from HTML content and normalize the URLs.
Installation
npm install extract-hrefsUsage
import { extractHrefs } from 'extract-hrefs';
const html = `
<!DOCTYPE html>
<html lang="en">
<head>
this is test
</head>
<body>
<p>
<a href="https://example.com">Example</a>
<a href="https://example.com/test">Example Test</a>
</p>
</body>
`;
const links = extractHrefs(html);
console.log(links);Output
[ 'https://example.com/', 'https://example.com/test' ]If you like my work, please consider giving it a star on GitHub or Sponsor my work by following sponsoring me link.
