You've successfully subscribed to MyPad Blog
Great! Next, complete checkout for full access to MyPad Blog
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.
Success! Your billing info is updated.
Billing info update failed.

Parse and save data from webpage console to the disk

Parse and save data from webpage console to the disk

For a research project, we needed to extract data from a webpage and save it to the disk before injecting it into our analytics pipeline.

Here is a way to accomplish it.

Browse to the Webpage

For demonstration, we will extract all companies in the website:


Inject jQuery

The first step is to inject jquery into the webpage if it is not already available. An easy way to do it is to use the jQuerify extension

Get data from the DOM

Inspect the DOM and get the required data

// get the companies data
var companies = $('select.lbxCompanySelection option');
var companies_arr = [];

companies.each(function(index, companie){
     // console.log(companie);
     var a = new Object(); = $(companie).attr('value'); = $(companie).text().trim();
     // console.log(a);


Create the function for saving data

In devtools, create the function for saving data

 // credit:
 // credit:

(function(console) { = function(data, filename) {

        if (!data) {
            console.error(' No data');

        if (!filename) {
            filename = 'console.json';

        if (typeof data === 'object') {
            data = JSON.stringify(data, undefined, 4);

        var blob = new Blob([data], {type: 'text/json'}),
            e    = document.createEvent('MouseEvents'),
            a    = document.createElement('a'); = filename;
        a.href = window.URL.createObjectURL(blob);
        a.dataset.downloadurl =  ['text/json',, a.href].join(':');
        e.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);

Save data, 'companies.json');

Voila! There you have the required data in the ~/Downloads directory.

Display data in console

Bonus! Here are some cool ways to see the data

# credit: [bash - How to format a JSON string as a table using jq? - Stack Overflow](

cat ~/Downloads/companies.json | jq -r '.[] | "\(.id)\t\(.name)"' | head

cat ~/Downloads/companies.json | jq -r '.[] | [.id, .name] | @tsv' | head

cat ~/Downloads/companies.json | jq -r '["ID","NAME"], ["--","------"], (.[] | [.id, .name]) | @tsv' | head

cat ~/Downloads/companies.json | jq -r '(["ID","NAME"] | (., map(length*"-"))), (.[] | [.id, .name]) | @tsv' | head

Now you are ready to run it through your analytics pipeline!