Skip to content

Instantly share code, notes, and snippets.

@jaseclamp
Created January 11, 2018 05:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaseclamp/e136a4bc61e0b961524b3bd57a14f931 to your computer and use it in GitHub Desktop.
Save jaseclamp/e136a4bc61e0b961524b3bd57a14f931 to your computer and use it in GitHub Desktop.
Run in browser console to scrape exhibitor list found at https://nrfbigshow.nrf.com/exhibitors
function tabValues(array) {
var keys = Object.keys(array[0]);
var result = keys.join("\t") + "\n";
array.forEach(function(obj){
keys.forEach(function(k, ix){
if (ix) result += "\t";
result += obj[k];
});
result += "\n";
});
return result;
}
var exhibitors = [];
jQuery.each( jQuery('div.view-id-Exhibitor_List table tbody tr a'), function(i,value){
exhibitors[i] = {};
exhibitors[i].company = jQuery(this).text();
exhibitors[i].link = jQuery(this).attr('href');
jQuery.ajax( { url: exhibitors[i].link, async:true, success: function( html ) {
exhibitors[i].state = jQuery(html).find('div.company_contact_city_state').text();
exhibitors[i].country = jQuery(html).find('div.company_country').text();
exhibitors[i].desc = jQuery(html).find('div.view-content span.field-content').text();
exhibitors[i].website = jQuery(html).find('div.company_website a').attr('href');
exhibitors[i].linkedin = jQuery(html).find('div.company_linkedin a').attr('href');
exhibitors[i].twitter = jQuery(html).find('div.company_twitter a').attr('href');
exhibitors[i].facebook = jQuery(html).find('div.company_facebook a').attr('href');
exhibitors[i].youtube = jQuery(html).find('div.company_youtube a').attr('href');
exhibitors[i].categories = jQuery.map( jQuery(html).find('a[href*="product-category"]'), function( n, i ) {
return ( jQuery(n).attr('href').substring(18) );
});
} } );
//if (i > 3) return false;
});
jQuery(document).ajaxStop(function(){
var tsv = tabValues(exhibitors);
console.log(tsv);
var hiddenElement = document.createElement('a');
hiddenElement.href = 'data:text/csv;charset=utf-8,' + encodeURI(tsv);
hiddenElement.target = '_blank';
hiddenElement.download = 'nrf-exhibs.csv';
hiddenElement.click();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment