All Projects → cyrus-and → Chrome Har Capturer

cyrus-and / Chrome Har Capturer

Licence: mit
Capture HAR files from a Chrome instance

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Chrome Har Capturer

Chrome Remote Interface
Chrome Debugging Protocol interface for Node.js
Stars: ✭ 3,603 (+751.77%)
Mutual labels:  browser, headless, google-chrome
Navalia
A bullet-proof, fast, and reliable headless browser API
Stars: ✭ 950 (+124.59%)
Mutual labels:  automation, browser, headless
Triflejs
Headless automation for Internet Explorer
Stars: ✭ 815 (+92.67%)
Mutual labels:  automation, browser, headless
Kasaya
A "WYSIWYG" (sort of) scripting language and runtime for browser automation
Stars: ✭ 1,906 (+350.59%)
Mutual labels:  automation, browser
Chrome Devtools Protocol
Chrome Devtools Protocol client for PHP
Stars: ✭ 112 (-73.52%)
Mutual labels:  automation, headless
Foot traffic
Pure Ruby DSL for Chrome scripting based on Ferrum. No Selenium required. Works from any script. Simulate web app usage scenarios in production or locally.
Stars: ✭ 123 (-70.92%)
Mutual labels:  automation, browser
Bookmarklet Maker
Tool to create bookmarklet/ javascript apps to automate the web browser.
Stars: ✭ 52 (-87.71%)
Mutual labels:  automation, browser
Bas
BrowserAutomationStudio can automate everything that Chrome can.
Stars: ✭ 203 (-52.01%)
Mutual labels:  automation, browser
Headless Burp
Automate security tests using Burp Suite.
Stars: ✭ 192 (-54.61%)
Mutual labels:  automation, headless
Nightwatch Cucumber
[DEPRECATED] Cucumber.js plugin for Nightwatch.js.
Stars: ✭ 243 (-42.55%)
Mutual labels:  automation, browser
Playwright Go
Playwright for Go a browser automation library to control Chromium, Firefox and WebKit with a single API.
Stars: ✭ 272 (-35.7%)
Mutual labels:  automation, headless
Wpt
Test suites for Web platform specs — including WHATWG, W3C, and others
Stars: ✭ 3,573 (+744.68%)
Mutual labels:  browser, google-chrome
Instagram Profilecrawl
💻 Quickly crawl the information (e.g. followers, tags, etc...) of an instagram profile. No login required!
Stars: ✭ 110 (-74%)
Mutual labels:  automation, browser
Cli
Get a programmable email address. Automate what happens when you receive emails. It's like Zapier for devs who hate emails.
Stars: ✭ 105 (-75.18%)
Mutual labels:  automation, headless
Brotab
Control your browser's tabs from the command line
Stars: ✭ 137 (-67.61%)
Mutual labels:  automation, browser
Rod
A Devtools driver for web automation and scraping
Stars: ✭ 1,392 (+229.08%)
Mutual labels:  automation, headless
Python Scripts
Collection of Various Python Script's.💻
Stars: ✭ 195 (-53.9%)
Mutual labels:  automation, browser
Undetected Chromedriver
Custom Selenium Chromedriver | Zero-Config | Passes ALL bot mitigation systems (like Distil / Imperva/ Datadadome / CloudFlare IUAM)
Stars: ✭ 365 (-13.71%)
Mutual labels:  automation, browser
Ferrum
Headless Chrome Ruby API
Stars: ✭ 1,009 (+138.53%)
Mutual labels:  automation, headless
Taiko
A node.js library for testing modern web applications
Stars: ✭ 2,964 (+600.71%)
Mutual labels:  automation, headless

chrome-har-capturer Build Status

Capture HAR files from a Chrome instance.

Under the hood this module uses chrome-remote-interface to instrument Chrome.

Screenshot

Setup

Install this module from NPM:

npm install chrome-har-capturer

Start Chrome like this:

google-chrome --remote-debugging-port=9222 --headless

Command line utility

The command line utility can be used to generate HAR files from a list of URLs. The following options are available:

-h, --help               output usage information
-t, --host <host>        Chrome Debugging Protocol host
-p, --port <port>        Chrome Debugging Protocol port
-x, --width <dip>        frame width in DIP
-y, --height <dip>       frame height in DIP
-o, --output <file>      write to file instead of stdout
-c, --content            also capture the requests body
-k, --cache              allow caching
-a, --agent <agent>      user agent override
-b, --block <URL>        URL pattern (*) to block (can be repeated)
-H, --header <header>    Additional headers (can be repeated)
-i, --insecure           ignore certificate errors
-g, --grace <ms>         time to wait after the load event
-u, --timeout <ms>       time to wait before giving up with a URL
-r, --retry <number>     number of retries on page load failure
-e, --retry-delay <ms>   time to wait before starting a new attempt
-f, --abort-on-failure   stop after the first failure (incompatible with parallel mode)
-d, --post-data <bytes>  maximum POST data size to be returned
-l, --parallel <n>       load <n> URLs in parallel

Library

Alternatively this module provides a simple API that can be used to write custom applications. See the command line utility source code for a working example.

API

run(urls, [options])

Start the loading of a batch of URLs. Returns an event emitter (see below for the list of supported events).

urls is array of URLs.

options is an object with the following optional properties:

  • host: Chrome Debugging Protocol host. Defaults to localhost;

  • port: Chrome Debugging Protocol port. Defaults to 9222;

  • width: frame width in DIP. Defaults to a Chrome-defined value;

  • height: frame height in DIP. Defaults to a Chrome-defined value;

  • content: if true also capture the requests body. Defaults to false;

  • cache: if true allow caching. Defaults to false;

  • timeout: milliseconds to wait before giving up with a URL;

  • retry: number of retries on page load failure. Defaults to 0;

  • retryDelay: time to wait before starting a new attempt. Defaults to 0;

  • abortOnFailure: stop after the first failure (incompatible with parallel mode);

  • postData: maximum POST data size (in bytes) to be returned. Defaults to unlimited;

  • parallel: if true load the URLs in parallel (warning: this may spoil time-based metrics). Defaults to false;

  • preHook: function returning a Promise executed before each page load:

    • url: the current URL;
    • client: CDP client instance;
    • index: index of url in urls;
    • urls: input URL array.
  • postHook: function returning a Promise executed after each page load event:

    • url: the current URL;
    • client: CDP client instance;
    • index: index of url in urls;
    • urls: input URL array.

    If this hook resolves to a value then it is included in the resulting HAR object as the value of the _user key of the this URL's page object.

Event: 'load'
function (url, index, urls) {}

Emitted when Chrome is about to load url. index is the index of url in urls. urls is the array passed to run().

Event: 'done'
function (url, index, urls) {}

Emitted when Chrome finished loading url. index is the index of url in urls. urls is the array passed to run().

Event: fail'
function (url, err, index, urls) {}

Emitted when Chrome cannot load url. The Error object err contains the failure reason. Failed URLs will not appear in the resulting HAR object. index is the index of url in urls. urls is the array passed to run().

Event: 'har'
function (har) {}

Emitted when all the URLs have been processed. If all the URLs fails then a valid empty HAR object is returned. har is the resulting HAR object.

fromLog(url, log, [options])

Generate a single-page HAR from an array of raw events that comes from the Chrome Debugging Protocol (e.g., from chrome-remote-interface). Returns a Promise that fulfills to the generated HAR.

url is the page URL;

log is the array of events in the form:

{
    method: '...',
    params: {...}
}

Events to be provided are:

  • Page.domContentEventFired;
  • Page.loadEventFired;
  • Network.requestWillBeSent;
  • Network.dataReceived;
  • Network.responseReceived;
  • Network.resourceChangedPriority;
  • Network.loadingFinished;
  • Network.loadingFailed.

Additional events for WebSockets are:

  • Network.webSocketWillSendHandshakeRequest;
  • Network.webSocketHandshakeResponseReceived;
  • Network.webSocketClosed;
  • Network.webSocketFrameSent;
  • Network.webSocketFrameReceived.

options is an object with the following optional properties:

  • content: if true also expect the requests body. Defaults to false.

When content is true synthetic events in the following form are also expected:

{
    method: 'Network.getResponseBody',
    params: {
        requestId: '...',
        body: '...',
        base64Encoded: true/false
    }
}

These events contain the reply of the Network.getResponseBody method, this is needed because Chrome does not return the body content via events, instead it must be requested manually and the reply must be appended to the other events in the log.

Resources

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].