scrapeByCssPath

Overview

Scrape any part of a webpage using the CSS Path.

Check this article on how to scrape web pages using CSS selectors.

Basically, if you click on the element that you want to scrape, right click > inspect element then a sidebar will appear. Right click on the HTML element that you've inspected and click on Copy > Copy Selector.

That's it! You'll have the CSS Path copied in your clipboard

Credits cost per execution

This function spends 1 credit per execution

Video example

Arguments

  • url: The URL you want to scrape (i.e. https://www.domain.com/path-1)

  • scrapeSeveralElements: Set to True if you want to scrape several elements. For default is set to False so it will scrape only the first element

  • cssPath: The CSS Path to select the element you want to scrape (i.e.h3)

  • method The method to use to get the element (i.e. textcontent)

Expected output

  • string: The element you want to scrape

Text example

scrapeByCssPath("https://www.npmjs.com/package/seo-scraper", TRUE, "h2", "textContent")
// seo-scraper
// Installing
// Get started with default config
// Custom Configuration
// Custom scraping example
// Transformers
// Keywords

Use cases

  • Scrape any website from Google Sheets

Last updated