Skip to content

Instantly share code, notes, and snippets.

@sivcan
Created May 23, 2020 22:33
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save sivcan/c002a92daddd8c8c9e6919f712136e26 to your computer and use it in GitHub Desktop.
Save sivcan/c002a92daddd8c8c9e6919f712136e26 to your computer and use it in GitHub Desktop.
Scrape Airtable [Script]
/**
1. Observed the Network tab in chrome devtools
2. Found out the request that has all the data
3. Right click the data (response of the network request) -> Store as global variable (this basically makes the entire data
available in the Console of DevTools) - it’s stored under a variable called as temp1
3. Figured out by writing _.VERSION in the console that Lodash library was available, so I can use that to convert my data.
4. Observed the payload, figured out how columnIds are mapped to the data that is present in the entire response JSON.
5. Wrote the following scripts to access the data:
**/
let columns = temp1.table.columns,
identifierMap = {
'Company name': 'name',
'Last modified': 'lastModified',
'Where to apply': 'url'
};
function getData (row) {
return _.reduce(columns, (acc, column) => {
if (_.includes(['Company name', 'Where to apply', 'Last modified', 'Status'], column.name)) {
if (row.cellValuesByColumnId[column.id]){
if (column.name === 'Status') {
let statuses = row.cellValuesByColumnId[column.id];
statuses = _.map(statuses, (status) => {
return _.find(temp1.table.columns[1].typeOptions.choices, { id: status }).name;
});
acc.status = statuses;
}
else {
acc[identifierMap[column.name]] = row.cellValuesByColumnId[column.id];
}
}
}
return acc;
}, {});
}
let data = _.map(temp1.table.rows, (row) => {
return getData(row);
}, {});
copy(data); // Copies the entire data to CLIPBOARD!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment