Skip to content

Instantly share code, notes, and snippets.

@evianzhow
Created March 4, 2019 09:59
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 evianzhow/2c251e6f6859f5599119e977c8d72bde to your computer and use it in GitHub Desktop.
Save evianzhow/2c251e6f6859f5599119e977c8d72bde to your computer and use it in GitHub Desktop.
const contList = document.querySelector('.contList');
const mailAddresses = [];
contList.querySelectorAll('ul').forEach(function(node) {
const name = node.querySelector('.firstLine').textContent.trim();
const mail_address = node.querySelector('.mailAddress').textContent.trim();
mailAddresses.push([name, mail_address]);
});
let csvContent = "data:text/csv;charset=utf-8,";
let rows = mailAddresses
rows.forEach(function(rowArray) {
let row = rowArray.join(",");
csvContent += row + "\r\n";
});
var encodedUri = encodeURI(csvContent);
window.open(encodedUri);
// http://phrogz.net/js/csv2vcard_2.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment