npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

web-scraper-headless-3

v1.0.1

Published

Web Scraper Headless allows to extract data from web pages using plans (sitemaps) created with the Web Scraper browser extension. Using these sitemaps the Web Scraper will navigate the site accordingly and extract all data. Scraped data later can be exp

Downloads

7

Readme

Web Scraper

Web Scraper is a chrome browser extension and a library built for data extraction from web pages. Using this extension you can create a plan (sitemap) how a web site should be traversed and what should be extracted. Using these sitemaps the Web Scraper will navigate the site accordingly and extract all data. Scraped data later can be exported as CSV.

To use it as an extension install it from [Chrome store] chrome-store

To use it as a library do npm i web-scraper-headless

Features

  1. Scrape multiple pages
  2. Sitemaps and scraped data are stored in browsers local storage or in CouchDB
  3. Multiple data selection types
  4. Extract data from dynamic pages (JavaScript+AJAX)
  5. Browse scraped data
  6. Export scraped data as CSV
  7. Import, Export sitemaps
  8. Depends only on Chrome browser

Help

Documentation and tutorials are available on webscraper.io webscraper.io

Ask for help, submit bugs, suggest features on [google groups] google-groups

Submit bugs and suggest features on [bug tracker] github-issues

Headless mode

To use it as a library you need a sitemap, you can write it by hand, but the easiest way is to use the original extension to scrape and then click on "export sitemap".

const webscraper = require('web-scraper-headless')
// visit github and retrieve last commit of all trending repo. 
// The sitemap depends on the actual DOM of github, so it might get outdated
const sitemap = {
     "startUrl": "https://github.com/trending",
     "selectors": [{
	      "parentSelectors": ["_root"],
	      "type": "SelectorLink",
	      "multiple": true,
	      "id": "link_to_repo",
	      "selector": "h3 a",
	      "delay": ""
     }, {
	      "parentSelectors": ["link_to_repo"],
	      "type": "SelectorText",
	      "multiple": false,
	      "id": "latest_commit",
	      "selector": "a.commit-tease-sha",
	      "regex": "",
	      "delay": ""
    }],
    "_id": "github_trending"
}
const options = {delay: 10, pageLoadDelay: 10, browser: 'headless'} // optional delay, pageLoadDelay and browser
webscraper(sitemap, options)
    .then(function (scraped) {
        // This is your scraped info
    })

By default webscraper-headless will open jsdom as a browser. This is a purely JS implementation of HTML. As such it has no native dependencies and it is very lightweighted. However, it is not capable of executing js which might be a hindrance in some cases. If that is your case, you can use chrome headless as a browser. Note that it will consume far more resources than jsdom and you need to have some native dependencies installed in the server. To use chrome headless do the following:

const sitemap = // same as previous example
const options = {browser: 'headless'}
webscraper(sitemap, options)
    .then(function (scraped) {
        // This is your scraped info
    })

Bugs

When submitting a bug please attach an exported sitemap if possible.

License

LGPLv3

Changelog

v0.2

  • Added Element click selector
  • Added Element scroll down selector
  • Added Link popup selector
  • Improved table selector to work with any html markup
  • Added Image download
  • Added keyboard shortcuts when selecting elements
  • Added configurable delay before using selector
  • Added configurable delay between page visiting
  • Added multiple start url configuration
  • Added form field validation
  • Fixed a lot of bugs

v0.1.3

  • Added Table selector
  • Added HTML selector
  • Added HTML attribute selector
  • Added data preview
  • Added ranged start urls
  • Fixed bug which made selector tree not to show on some operating systems