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

stack-scraper

v0.1.4

Published

Stack Scraper. Easily download complex web sites.

Downloads

3

Readme

Stack Scraper

Stack Scraper is a system for efficiently scraping information from complex web sites in a repeatable way, exporting directly to a data store.

Stack Scraper is good at collecting lots of semi-structured data from complicated, or even poorly-written, web sites in a repeatable manner.

Features

  • Scraping operations can be paused and resumed at a later time.
  • Fault tolerant.
  • Easy to scrape complex web sites, even ones with forms, pop-ups, JavaScript-based UIs, or other complexities.
  • No one-to-one relationship between URLs and data collected. Multiple sources of data can be collected from a single page and the ID of the data can be handled arbitrarily (for example, the ID for a page could actually be the name of an image on the page, or the MD5 of that image, or something else entirely).
  • Data for a single record can be collected, and compiled, from multiple, consecutive web pages. For example, let's say some data is on a page and then more data is within a popup. Both of those pages can be scraped and be combined into a single record.
  • The process for crawling, downloading, extracting data, and processing the data are all de-coupled. They can all be run back-to-back, or one-at-a-time, or even repeatedly.

Guide

See the example directory for a full sample scraper.

Stack Scraper provides the code to write a simple command-line application for downloading semi-structured data from complex web sites. However you'll need to take a number of things into consideration when you're building your stack-scraper implementation, namely:

  • Command-line Interface The implementation of the command-line utilty and where various utility files will be located.
  • Scrapers An implementation of a basic scraper.
  • File System Where downloaded files (html, images, etc.) will live.
  • Datastore and Data Models Where extracted data and scrape logs will be stored, and how.
  • Post-Processors If any post-processing on the extracted data will be completed and how to do it.

Command-line Interface

Arguments:

  • type: Type of scraper to load (e.g. 'images' or 'artists').
  • source: The name of the source to download (e.g. 'ndl' or '*').

Options:

  • --scrape: Scrape and process the results from the already-downloaded pages.
  • --process: Process the results from the already-downloaded pages.
  • --reset: Don't resume from where the last scrape left off.
  • --delete: Delete all the data associated with the particular source.
  • --debug: Output additional debugging information.
  • --test: Test scraping and extraction of a source.
  • --test-url: Test extraction against a specified URL.

Initialization Properties:

  • rootDataDir (String): A full path to the root directory where downloaded data is stored. (See "File System" for more information.)
  • scrapersDir (String): A full path to the directory where scraper .js files are stored. (See "Scrapers" for more information.)
  • directories (Object, optional): A key-value set of names of directories paired with the relative path to the directory. These directories will be created inside the individual source directory inside the rootDataDir. (See "File System" for more information.)
  • model (Function): A function representing the model in which extracted data will be stored. (See "Datastore and Data Models" for more information.)
  • logModel (Function): A function representing the log model for storing information about an in-progress site scrape. (See "Datastore and Data Models" for more information.)
  • postProcessors (Object, optional): An object whose keys are the names of model properties which should be processed and values are functions through which the data will be processed. (See "Post-Processors" for more information.)

Scrapers

File System

Datastore and Data Models

MongoDB + Mongoose

dbFind(filter:Object, callback)
dbFindById(id:String, callback)
dbSave(data:Object, callback)
dbUpdate(data:Object, newData:Object, callback)
dbRemove(filter:Object, callback)
dbLog(data:Object, callback)
dbStreamLog(filter:Object) -> Stream
dbRemoveLog(filter:Object, callback)

Post-Processors