GithubHelp home page GithubHelp logo

lexich / electron-har Goto Github PK

View Code? Open in Web Editor NEW

This project forked from shyiko/electron-har

0.0 1.0 0.0 73 KB

A command-line tool for generating HTTP Archive (HAR) (based on Electron)

Home Page: https://www.npmjs.com/package/electron-har

License: MIT License

JavaScript 99.65% HTML 0.35%

electron-har's Introduction

electron-har

A command-line tool for generating HTTP Archive (HAR) (based on Electron).

The data you get is identical to "Chromium -> Developer Tools -> Network pane -> Save All as HAR".

Installation

Prebuilt binaries can be found on the release(s) page.

You can also use npm:

npm install -g electron-har

In order for Electron to work on Debian/Ubuntu (specifically on Debian 8/Ubuntu 12.04) following packages have to be installed libgtk2.0-0 libgconf-2-4 libasound2 libxtst6 libxss1 libnss3.

Usage

NOTE for Linux users: you might need to --disable-gpu

# NOTE: on Linux --disable-gpu might be needed
electron-har http://google.com # writes HAR to stdout

# in case something doesn't look right / not working
ELECTRON_ENABLE_LOGGING=1 electron-har --disable-gpu --show http://google.com 2>electron.log

# in a headless environment (CI agent on Linux?) - xvfb-run will do just fine 
DISPLAY=:1 xvfb-run electron-har http://google.com -o google_com.har

# to see a complete list of command line options
electron-har --help

... or pragmatically

const electronHAR = require('electron-har')

electronHAR('http://enterprise.com/self-destruct', {
  user: {
    name: 'jean_luc_picard',
    password: 'picard_4_7_alpha_tango'
  }
}, function (err, json) {
  if (err) {
    throw err
  }
  console.log(json.log.entries)
})

In a headless environment you might want to use kesla/headless (which will start Xvfb for you).

const headless = require('headless')
const electronHAR = require('electron-har')

(function (cb) {
  if (!process.env.DISPLAY) {
    headless(function (err, proc, display) {
      if (err) {
        return cb(err)
      }
      process.env.DISPLAY = ':' + display
      cb(null, proc)
    })
  } else {
    process.nextTick(cb)
  }
})(function (err, xvfb) {
  if (err) {
    throw err
  }
  electronHAR(..., function (err, json) {
    ...
    xvfb && xvfb.kill()
  })
})

License

MIT License

electron-har's People

Contributors

bmcminn avatar lexich avatar shyiko avatar shyykoserhiy avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.