Skip to content

Instantly share code, notes, and snippets.

@nodaguti
Created February 9, 2017 04:07
Show Gist options
  • Save nodaguti/d5e4910df08dcdfdff1437d5d50b14f9 to your computer and use it in GitHub Desktop.
Save nodaguti/d5e4910df08dcdfdff1437d5d50b14f9 to your computer and use it in GitHub Desktop.
tango-cho.com to CSV
/**
* Convert a phrase list on tango-cho.com into CSV-formatted text.
* Usage:
* i) Copy and paste into your browser's console.
* ii) Run it!
*/
(() => {
const wrappers = document.querySelectorAll('.top_list > tbody > tr');
const csv = [];
Array.from(wrappers).forEach((wrapper) => {
const tds = wrapper.getElementsByTagName('td');
const word = tds[0].textContent.trim();
const def = tds[1].textContent.trim();
csv.push(`"${word}","${def}"`);
});
console.log(csv.join('\n'));
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment