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

browser-networking

v0.1.4

Published

View all browser networking requests for a certain url via PhantomJS

Downloads

8

Readme

NPM

GitHub version npm version dependencies

Install

run npm install. This installs one dependecy:

  • phantom: https://www.npmjs.com/package/phantom

Test

To run the tests execute npm test. Please install the dev dependencies first.

When to use this

Please note that executing the browserNetworking.request function is insanely slow compared to normal HTTP networking (which is slow already). This package should only be used if speed is not an issue.

Example implementations:

  • Check wether or not a certain website includes your banner or copyright image
  • Check if certain scripts make certain calls as expected (for testing maybe, but there are better ways to achieve that)

It is recommended to run the script from a queue or cronjob in seperate non-blocking calls. The process is CPU intensive. This is what happens:

  • The request function is called with an URL
  • PhantomJS is started. PhantomJS is a headless browser (no GUI).
  • We navigate to the given URL
  • We wait for the page to completely load and catch all called URLs
  • We return the result and close the workers in the background

API

Exposes a request function which takes one argument: the url of the request. The function returns a Promise. The promises resolves to an Array of urls or rejects to an error object.

Example

browserNetworking.request('http://www.google.com').then(urls => {

        // urls is an array of resources requested by the browser

    },
    error => {

        // handle error

    });

The result for Google (depending on your geolocation, the IP, etc) would look something like this:

[ 'http://www.google.com/',
  'http://www.google.nl/?gfe_rd=cr&ei=gxQJWOlji9zwB_W1ssgI',
  'http://ssl.gstatic.com/gb/images/b_8d5afc09.png',
  'http://www.google.nl/images/branding/googlelogo/1x/googlelogo_white_background_color_272x92dp.png',
  'http://www.google.nl/images/nav_logo229.png',
  'http://www.google.nl/client_204?&atyp=i&biw=400&bih=300&ei=gxQJWKjUAonhaPyBsOAO',
  'http://www.google.nl/xjs/_/js/k=xjs.hp.en_US.e4-85eyk8Bs.O/m=sb_he,d/rt=j/d=1/t=zcms/rs=ACT90oGwhtLZKDuRRfajPNxXQ_iRSPiqWw',
  'http://clients1.google.nl/generate_204' ]