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

c-resolver

v1.2.1

Published

crawler tool

Downloads

5

Readme

c-resolver a tool for crawler

Installation

npm install c-resolver

example

get something you need from test.html

<html>
<head>
    <script type="text/javascript">
        let test = function () {
            return "tseian.com";
        }
    </script>
</head>
<body>
    <div class="divClass">
        <h1 class="h1Class">h1Text</h1>
        <input value="inputValue" />
        <ul class="ulClass">
            <li>l1</li>
            <li>l2</li>
            <li>l3</li>
            <li>l4</li>
        </ul>
    </div>
</body>
</html>
  • get attribute value
    • get class name from h1
          const define = {
              "name": "item",  
              "type": "item",  
              "process": "processItem", 
              "match": "/", 
              "filter": "div",  
              "define": 
                  [{
                      "name": "name",
                      "type": "att",
                      "att": "class",
                      "match": "./",
                      "process": "[COMMON_STR_PROCESS]",
                      "filter": "h1"
                  }]
          };
      
          function Test() {
              this.processItem = function (item) { //handle item befor output
                  return item;
              };
              return this;
          }
          let res = resolver(define, html, new Test());
          /**
           * res = {item:{name:"h1Class"}}
           * /
      
      
      • get a list from ul->li
         const define = {
              "name": "item",
              "type": "item",
              "process": "processItem",
              "match": "/",
              "filter": "ul",
              "define":
                  [{
                      "name": "list",
                      "match": "./",
                      "type": "list",
                      "filter": "li",
                      "process": "processList",
                      "define": [{
                          "name": "name",
                          "type": "text",
                          "process": "[COMMON_STR_PROCESS]",
                      }]
                  }]
          };
        
          class Test {
              processItem(item) {
                  return item;
              };
              processList(list) {
                  return list;
              }
          }
        
          let res = resolver(define, html, new Test());
          /**
           * res = {item:[{"name":"l1"},{"name":"l2"},{"name":"l3"},{"name":"l4"}]}
           * /

-there are more example

how define define&process

  • "name": "key", //outut obejct key
  • "type": "valueType", //value type:
    • item: output value is a object,
    • lis: output value is a array(collection)
    • text: output value is a string
    • att: output value is a string(if type is att, should define att value )
  • "att": "attName", //element attribute name
  • "process": "processItem", //a function excute before output with param
  • "match": "/", // cheerio will find element by selector(filter) in the following element object
    • '/' is root element obejct from cheerio.load(root element html)
    • "./" is father element object
  • "filter": "div", // element selector

process

must be a function and return output value you want