Created
April 18, 2019 09:57
-
-
Save ntkog/75baa7e0cd4599a68ea8c57096398845 to your computer and use it in GitHub Desktop.
Propuestas Partidos políticos según newtral
This file contains 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
function propuestas(partido) { | |
let lista = [...document.querySelectorAll('.e-module div[data-option]')].map(el=>({ | |
partido: el.dataset.option, | |
texto: [...el.querySelectorAll('p')].reduce((old,cur)=>old + cur.textContent, "") | |
})).filter(obj=> (partido === "all" ? true : obj.partido === partido) && obj.texto.length > 0); | |
partido === "all" ? console.table(lista) : console.table(lista,["texto"]); | |
let csv = lista.map(r => `"${r.partido}"|"${r.texto.replace(/\n/g, " ")}"`); | |
csv.unshift(`"partido"|"texto"`); | |
// Copia al portapapeles todos los datos a un CSV | |
copy(csv.join("\n")); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment