Chrome HAR Capturer - capture HAR files from a remote Chrome instance

3,736 views
Skip to first unread message

Andrea Cardaci

unread,
Jan 15, 2013, 10:56:25 PM1/15/13
to http-archive-...@googlegroups.com
Hello,
I had to perform several repetitive tests involving HAR generation and packet dumps, so I searched for a tool to automate the HAR part, at first I thought to use one of the several tools available (phantomjs, browsermob-proxy, pcap2har, etc.) but unfortunately none of them work with SPDY, so I decided to write a tool myself.

I wrote a Node.js module that instruments a remote instance of Google Chrome using its Remote Debugging Protocol and reconstructs HARs from the events generated by the browser.

I thought you guys would find it useful so I'm posting here, the code is available on GitHub. Any feedback would be greatly appreciated.

Regards,

Andrea

Steve Souders

unread,
Jan 16, 2013, 1:32:37 PM1/16/13
to http-archive-...@googlegroups.com
This is really awesome work, and it's nice to have it as a self-contained project. But I just want to point out that WebPagetest (also open source) connects to IE 6-10, Chrome, and FF (and iOS and some others) and generates HAR files. Numerous people & companies have private instances of WebPagetest, so that's another route to go. Although it's not hard to setup, it's probably more work than your project, so your work is valuable.

Thanks.

-Steve

Andrea Cardaci

unread,
Jan 17, 2013, 12:00:45 PM1/17/13
to http-archive-...@googlegroups.com
Hi Steve,
and thanks for your response. Yes, WebPagetest is definitely another route, I initially skipped it because I was missing the private instance part, I thought it was just an online service. Anyway thanks for pointing it out, I didn't try, but it looks like an awesome full featured tool that can do way more than my project that, on the other hand, requires almost no configuration.

Regards,

Shadow81

unread,
Oct 18, 2013, 7:03:17 AM10/18/13
to http-archive-...@googlegroups.com
Hi Andrea,

Its good work. However, your tool is not dumping cookie values in generated HAR file.
Do you have any work around?

regards,
Xb

Andrea Cardaci

unread,
Oct 18, 2013, 7:25:23 AM10/18/13
to http-archive-...@googlegroups.com
Hi, it's a feature not implemented yet. I'll fix it as soon as I find some free time.

Shadow81

unread,
Oct 18, 2013, 10:54:24 PM10/18/13
to http-archive-...@googlegroups.com
Can you give me some pointers. How to fix it? I will try to make update in it.

lesterzone

unread,
Dec 12, 2013, 4:04:18 PM12/12/13
to http-archive-...@googlegroups.com
Hello,
After say thanks for this awesome project(I also checked chrome-remote-interface) I have a little question,
I'm dealing with a basic idea: get basic information about network like url, response code, response content(json response from the server not just headers and other information) So after read code and Debugger Documentation I found this
https://developers.google.com/chrome-developer-tools/docs/protocol/1.0/network#command-getResponseBody which looks something like what I need.

Do you think I can get the 'real' response using chrome-har-capturer tool?

I'm not sure if I need to read/research more about it or sleep before moving forward.

Thanks for your time.

Andrea Cardaci

unread,
Dec 20, 2013, 9:40:28 AM12/20/13
to http-archive-...@googlegroups.com
Hi, and sorry for this delay, but I had a quite busy week...

First of all, thanks, I'm glad you find it useful! :)

chrome-har-capturer doesn't support this feature because I wasn't Interested to the actual response bytes, but if I understand correctly your requirements, you can write your own tool fairly easily using chrome-remote-interface, here's an example:
var Chrome = require('chrome-remote-interface');
Chrome(function (chrome) {
    with (chrome) {
        on('Network.responseReceived', function (message) {
            var mimeType = message.response.mimeType;
            var status = message.response.status;
            if (status === 200 && mimeType === 'application/json') {
                var params = {'requestId': message.requestId};
                Network.getResponseBody(params, function (err, response) {
                    console.log(response.body);
                });
            }
        });
        on('Page.loadEventFired', close);
        Network.enable();
        Page.enable();
        Page.navigate({'url': 'https://github.com/cyrus-and/chrome-remote-interface'});
    }
}).on('error', function () {
    console.error('Cannot connect to Chrome');
});
Cheers,

Andrea

lesterzone

unread,
Dec 20, 2013, 2:20:53 PM12/20/13
to http-archive-...@googlegroups.com
Awesome,
Thanks, I'll work with this!

Once again thanks for your reply.

Ovi Wan-Kenobi

unread,
Mar 29, 2016, 8:17:12 AM3/29/16
to HTTP Archive Specification
hi Andrea

thank you for sharing this with us. I have a question, I need to use this component on windows clients; I am not sure how fortunate is to go ahead and try to adapt it for windows. I am not sure what implies when you say "I wrote a nodes.js module"... it means it can run only on a node.js server? is there any chance I wold be able to adapt it to run stand alone on a windows client?

thank you

Andrea Cardaci

unread,
Mar 29, 2016, 1:27:04 PM3/29/16
to HTTP Archive Specification
Hi,

> I am not sure what implies when you say "I wrote a nodes.js module"... it means it can run only on a node.js server?

Exactly.

> is there any chance I wold be able to adapt it to run stand alone on a windows client?

A standalone Windows client would be a complete rewrite... But since Node.js is available also for Windows you can just use it as is.
Hope it helps.


Best,

Andrea

Siva Kesava

unread,
Jan 12, 2017, 11:27:03 AM1/12/17
to HTTP Archive Specification
Hello,
After say thanks for this awesome project(I also checked chrome-remote-interface) I have a little question, can we capture HAR for a video after the video finishes playing say for youtube I start a video and then download the HAR at the end of the video. I saw that you have a delay option but if I don't know the time the video will take to play is there any option to check whether the video is playing and then download if it has ended.

Thanks
Siva Kesava

Andrea Cardaci

unread,
Jan 12, 2017, 1:04:32 PM1/12/17
to HTTP Archive Specification
Hi Siva,
unfortunately there's no easy way to do that at the moment, I'm afraid the best you can do is to set a sufficiently large delay timeout, larger than any video you're going to play. 

Best,
Andrea
Reply all
Reply to author
Forward
0 new messages