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

pcrawl

v1.0.2

Published

```bash $ npm i pcrawl -g $ pcrawl -c ./config.yml -o ./result.json ``` ## args ```js parser.add_argument("-v", "--version", { action: "version", version, }); parser.add_argument("-c", "--config", { help: "配置文件", }); parser.add_argument("-o", "--out

Downloads

3

Readme

Quick Start

$ npm i pcrawl -g
$ pcrawl -c ./config.yml -o ./result.json

args

parser.add_argument("-v", "--version", {
  action: "version",
  version,
});
parser.add_argument("-c", "--config", {
  help: "配置文件",
});
parser.add_argument("-o", "--output", {
  help: "输出到目标文件",
});
parser.add_argument("-j", "--jquery", {
  help: "是否注入jquery到yemain, true| false, defalut false",
});
parser.add_argument("--log", {
  help: "开启log true|false,default false",
});

config.yml

| name | instructions | | ------------ | ------------------------------------------------------------ | | url | 要爬取的页面地址 | | wait | 爬取的dom标识,一旦这个类或者id出现则开始爬取 | | until | 结束标识,一旦出现这个类或id则停止 | | next | 爬取下一页的行为 如 "click xxx" xxx是个class或id | | dataItemFunc | 脚本路径,每次页面wait标识激活后则执行当前方法 | | authUrl | 认证地址,如果需要登录可以填写登录地址,加载后会等待10给你输入密码时间 | | authActions | 如果需要自动化处理登录认证也可在这里配置一系列action,puppeteer |

dataItemFunc

  1. 必须定义一个 $main函数
  2. 必须返回一个数组

demo

$ pcrawl -c ./config.yml -o ./result.json

config.yml

instpaaper:
  url: https://www.instapaper.com/u
  wait: .paginate_older
  until: not .paginate_older
  next: click .paginate_older
  dataItemFunc: ./dataItemFunc.js
  authUrl: https://www.instapaper.com/user/login
  authActions:
    - "type #username [email protected]"
    - "type #password yunfeng0409"
    - "click #log_in"

script.js

function $main(args) {
    try {
        const itemList = $('.article_item').toArray();
        const data = itemList.map(v => {
            const find = (className) => {
                return $($(v).find(className)[0])
            };
            const title = find('.article_title').text();
            const desc = find('.article_preview').text();
            const originUrl = find('.js_domain_linkout').get(0).href;
            const result = {
                title,
                desc,
                originUrl,
            }
            return result;
        })
        return data
    } catch (e) {
        console.log(e)
        return []
    }
}