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

mrcrowley

v0.0.7

Published

Retrieve data from different websites using html elements to gather the information you need.

Downloads

11

Readme

MrCrowley

Retrieve data from different websites using html elements to gather the information you need.

Build Status


Installation

npm install -g mrcrowley
mrcrowley --config="/home/user/.crawl.json" --save="/home/user/crawlResults.json"

Usage

Core usage

I still have to document how you can require and use the core directly but just so that you know, you can do it and the results are based on promises.

CLI

Set a .crawl.json and run all the tasks you want when you pass it to mrcrowley.

Note: Any kind of path should be absolute or relative to the place the script is called.

mrcrowley --config=<config_json_src> --output=<file_to_save_src> --force=<false|true>

Notes:

  • <config_json_src>: Path to the config json for crawling. It is required
  • <file_to_save_src>: Path for the file you want to have the results. For now, only json is supported. It is required
  • force: It forces to create a new output. If false and the output file exists, it will just update. It will default to false

Configuration

{
    "projectId": "<project_id>",
    "projectName": "<project_name>",
    "data": [{
        "src": "<url_path>",
        "name": "<request_name>",
        "throttle": 2000,
        "enableJs": false,
        "waitFor": "<html_selector>",
        "wait": {
            "selector": "<html_selector>",
            "for": 5000
        },
        "modifiers": {
            "<query_var_in_url>": ["<var_to_replace>"]
        },
        "retrieve": {
            "<name>": {
                "selector": "<html_selector>",
                "attribute": "<attribute_to_retrieve>",
                "ignore": ["<regex_pattern_to_ignore>"]
            }
        }
    }]
}

Notes:

  • retrieve: Besides the simplified version, you may also nest it to get contained data

    {
        "src": "...",
        "retrieve": {
            "<name>": {
                "selector": "<parent_html_selector>",
                "retrieve": {
                    "<name>": {
                        "selector": "<child_html_selector>",
                        "attribute": "<attribute_to_retrieve>",
                        "ignore": ["<regex_pattern_to_ignore>"]
                    }
                }
            }
        }
    }
  • attribute: If not provided, text content will be returned. Optional key.

  • ignore: Ignore results with a regex pattern. Optional key.

  • enableJs: Javascript isn't enable by default for security reasons. Use this if you really need it

  • wait: Usually used with enableJs. If the sources uses javascript to render, you may wait for the selector to be present

  • <var_to_replace>: It can also be an object with keys min (it will default to 0) and max (it will default to 10)

    {
        "src": "...",
        "modifiers": {
            "<query_var_in_url>": ["<var_to_replace>"],
            "<limit_var_in_url>": [{
                "min": 0,
                "max": 10
            }]
        },
        "retrieve": {}
    }

Examples

Go under the src/_test/data folder and check the *.json.