web-element-scraper

1.0.6 • Public • Published

Element Scraper

Element Scraper is a Node.js package designed to easily scrape text content from HTML elements on web pages. It utilizes Puppeteer for headless browsing and Cheerio for parsing HTML.

Installation

To install Element Scraper, simply run:

npm install web-element-scraper

Usage

Element Scraper provides a simple interface for scraping text from HTML elements on a web page.

const { scrape, scrapeMultiple } = require("web-element-scraper");

// Scrape single element
scrape("https://example.com", "h1")
  .then((titles) => {
    console.log("H1 Titles:", titles);
  })
  .catch((error) => {
    console.error(error);
  });

// Scrape multiple elements
scrapeMultiple("https://example.com", ["h1", "h2", "p"])
  .then((results) => {
    console.log("Scraped Data:", results);
  })
  .catch((error) => {
    console.error(error);
  });

Parameters

  • url (string): The URL of the web page you want to scrape.
  • element / elements (string / [string]): The HTML element(s) you want to scrape.

Return Value

  • Returns an array of strings containing the text content of the scraped elements.

Dependencies

  • Puppeteer: Headless browser automation library.
  • Cheerio: Fast, flexible, and lean implementation of core jQuery for the server.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Readme

Keywords

Package Sidebar

Install

npm i web-element-scraper

Weekly Downloads

12

Version

1.0.6

License

MIT

Unpacked Size

7.09 kB

Total Files

5

Last publish

Collaborators

  • ajeermdk