Created
February 9, 2017 04:07
-
-
Save nodaguti/d5e4910df08dcdfdff1437d5d50b14f9 to your computer and use it in GitHub Desktop.
tango-cho.com to CSV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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