Parsed HTML document
OptionalbaseUrl: string | URL | nullBase URL for resolving relative links and determining internal/external
Extraction options for filtering and categorization
Links metadata with categorized links
Extracts all <a href> links with comprehensive metadata and filtering options.
Perfect for crawlers, SEO analysis, and link discovery.
Features:
const doc = parseHTML(htmlString);
const links = extractLinks(doc, 'https://example.com');
// Get all internal links (same origin)
console.log(links.internal);
// Get external links excluding nofollow
const linksNoFollow = extractLinks(doc, 'https://example.com', {
scope: 'external',
excludeRel: ['nofollow']
});
Extract links from parsed HTML document.