Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
cheerio-to-text
Advanced tools
Explained by an example:
import fs from "fs"
import cheerio from "cheerio"
import { render } from "cheerio-to-text"
const html = fs.readFileSync("page.html", "utf-8")
console.log(html)
//
// <!doctype html>
// <body>
// <div id="main">
// <p>Para<strong>graph</strong>.</p>
// <ul><li>Foo</li><li>Bar</li></ul><h3>Heading</h3>
// </div>
// </body>
//
const $ = cheerio.load(html)
console.log($("div#main").text())
//
// Paragraph.
// FooBarHeading
//
console.log(render($("div#main")))
//
// Paragraph.
// Foo
// Bar
// Heading
//
Much of the origin of this that GitHub Docs scrapes
every page with got
and cheerio
and then needs to convert that into an
appropriate string of plain text that it can use for searching
with Elasticsearch. Using myCheerioObject.text()
isn't good enough
because it lumps together HTML blocking tags that have no whitespace
between the >
and the next <
.
MIT
Run npm run build:watch
in one terminal the look at
example.mjs
(which you run with node example.mjs
)
jest
Or
jest --watch -t "some test text"
FAQs
Turn a Cheerio object into plain text
The npm package cheerio-to-text receives a total of 1,363 weekly downloads. As such, cheerio-to-text popularity was classified as popular.
We found that cheerio-to-text demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.