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

seenreq

v3.0.0

Published

A library to test if a url(request) is crawled, usually used in a web crawler. Compatible with `request` and `node-crawler`

Downloads

14,255

Readme

NPM

build status Dependency Status NPM download NPM quality

seenreq

A library to test if a url/request is crawled, usually used in a web crawler. Compatible with request and node-crawler. The 1.x or newer version has quite different APIs and is not compatible with 0.x versions. Please read the upgrade guide document.

Table of Contents

Quick Start

Installation

$ npm install seenreq --save

Basic Usage

const seenreq = require('seenreq')
, seen = new seenreq();

//url to be normalized
let url = "http://www.GOOGLE.com";
console.log(seen.normalize(url));//{ sign: "GET http://www.google.com/\r\n", options: {} }

//request options to be normalized
let option = {
    uri: 'http://www.GOOGLE.com',
    rupdate: false
};

console.log(seen.normalize(option));//{sign: "GET http://www.google.com/\r\n", options:{rupdate: false} }

seen.initialize().then(()=>{
    return seen.exists(url);
}).then( (rst) => {
    console.log(rst[0]);//false if ask for a `request` never see
    return seen.exists(opt);
}).then( (rst) => {
    console.log(rst[0]);//true if got same `request`
}).catch(e){
    console.error(e);
};

When you call exists, the module will do normalization itself first and then check if exists.

Use Redis

seenreq stores keys in memory by default, memory usage will soar as number of keys increases. Redis will solve this problem. Because seenreq uses ioredis as redis client, all ioredis' options are recived and supported. You should first install:

npm install seenreq-repo-redis --save

and then set repo to redis:

const seenreq = require('seenreq')
let seen = new seenreq({
    repo:'redis',// use redis instead of memory
    host:'127.0.0.1', 
    port:6379,
    clearOnQuit:false // clear redis cache or don't when calling dispose(), default true.
});

seen.initialize().then(()=>{
    //do stuff...
}).catch(e){
    console.error(e);
}

Use mongodb

It is similar with redis above:

npm install seenreq-repo-mongo --save
const seenreq = require('seenreq')
let seen = new seenreq({
    repo:'mongo',
    url:'mongodb://xxx/seenreq',
    collection: 'foor'
});

Class:seenreq

Instance of seenreq

seen.initialize()

Initialize the repo, returns a promise.

seen.normalize(uri|option[,options])

Returns normalized Object: {sign,options}.

seen.exists(uri|option|array[,options])

Returns a promise with an Boolean array, e.g. [true, false, true, false, false].

seen.dispose()

Dispose resources of repo. If you are using repo other than memory, like Redis you should call dispose to release connection. Returns a promise.

Options

  • removeKeys: Array, Ignore specified keys when doing normalization. For instance, there is a ts property in the url like http://www.xxx.com/index?ts=1442382602504 which is timestamp and it should be same whenever you visit.
  • stripFragment: Boolean, Remove the fragment at the end of the URL (Default true).
  • rupdate: Boolean, it is short for repo update. Store in repo so that seenreq can hit the same req next time (Default true).

RoadMap

  • add mysql repo to persist keys to disk.
  • add keys life time management.