Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@axeptio/links-classifier

Package Overview
Dependencies
Maintainers
9
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@axeptio/links-classifier

This library is used to filter and classify links inside a web page, works with any language.

  • 0.0.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
10
increased by100%
Maintainers
9
Weekly downloads
 
Created
Source

Use Case

We want to filter links from a given webpage and classify them into different document types, like Privacy Policy, Terms of Service, etc.

Approach

We expose two functions, one for filtering the links, removing external, invalid and duplicate links, and another one for classifying the links into different document types.

Usage


const { filterLinks, classifyLinks, keywords } = require('links-classifier');

const links = document.querySelectorAll('a');

const filteredLinks = filterLinks(
  links, // the links to filter
  window.location, // the context
  ['en', 'fr', 'it'], // valid locales (other languages will be ignored)
  false, // follow subdomains
  console.log // logger function
);

const classifiedLinks = classifyLinks(filteredLinks, keywords, 'fr');

console.log(classifiedLinks);

/*
{
 'privacy_policy': Array(2),
 'terms_of_service': Array(1),
}
 */

Data

This module imports its own dataset, located in data/keywords.js, which contains variations for each document type. It is exposed as a symbol from the index, but you are free to use your own dataset.

FAQs

Package last updated on 27 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc