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

cheerio-select

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cheerio-select

Selector engine for cheerio

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4M
decreased by-40.85%
Maintainers
1
Weekly downloads
 
Created

What is cheerio-select?

The cheerio-select npm package is a library that allows users to use CSS selectors to select and manipulate HTML elements within a cheerio instance. It is designed to work with the cheerio library, which is a fast, flexible, and lean implementation of core jQuery designed specifically for the server.

What are cheerio-select's main functionalities?

Selecting elements

This feature allows you to select HTML elements using CSS selectors. In the code sample, we select elements with the class 'apple' and log their text content.

const cheerio = require('cheerio');
const select = require('cheerio-select');
const html = '<ul id="fruits"><li class="apple">Apple</li><li class="orange">Orange</li></ul>';
const $ = cheerio.load(html);
const elements = select('.apple', $);
console.log($(elements).text()); // 'Apple'

Filtering elements

This feature allows you to filter a set of elements down to those that match a CSS selector. In the code sample, we filter a list of 'li' elements to only those with the class 'apple'.

const cheerio = require('cheerio');
const select = require('cheerio-select');
const html = '<ul id="fruits"><li class="apple">Apple</li><li class="orange">Orange</li></ul>';
const $ = cheerio.load(html);
const fruits = $('li').toArray();
const apples = select.filter('.apple', fruits, $);
console.log($(apples).text()); // 'Apple'

Other packages similar to cheerio-select

FAQs

Package last updated on 24 May 2012

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