
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
page-scraper
Advanced tools
Web page scraper with a jQuery-like syntax for Node. Powered by got and cheerio.
$ npm install page-scraper
const scrape = require('page-scraper');
(async () => {
const $ = await scrape('https://example.com');
// Extract the page with jQuery like syntax.
console.log({
title: $('title').text(),
heading: $('h1').text(),
paragraphs: $('p').map((index, el) => $(el).text()).get(),
link: $('p > a').attr('href')
});
})();
Check the cheerio documentation for a complete guide on how to scrape the page using jQuery like syntax.
const scrape = require('page-scraper');
(async () => {
try {
const $ = await scrape('https://httpbin.org/status/400');
} catch(error) {
// The error message.
console.error(error.message);
if (error.hasOwnProperty('response')) {
// The HTTP status code.
console.error(error.response.statusCode);
}
if (error.hasOwnProperty('$')) {
// The HTML document.
console.error(error.$.html());
}
}
})();
Note that if the page is not an HTML document, it will throw an error too.
const scrape = require('./src');
(async () => {
try {
const $ = await scrape('https://httpbin.org/json');
} catch(error) {
console.error(error.message);
if (error.hasOwnProperty('response')) {
// The response body.
console.error(error.response.body);
}
}
})();
const scrape = require('./src');
(async () => {
const $ = await Promise.all([
scrape('https://example.com'),
scrape('https://httpbin.org/html')
]);
console.log({
heading_1: $[0]('h1').text(),
heading_2: $[1]('h1').text()
});
})();
FAQs
Web page scraper with a jQuery-like syntax for Node.
We found that page-scraper 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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.