Skip to content

Instantly share code, notes, and snippets.

@ntkog
Created April 18, 2019 09:57
Show Gist options
  • Save ntkog/75baa7e0cd4599a68ea8c57096398845 to your computer and use it in GitHub Desktop.
Save ntkog/75baa7e0cd4599a68ea8c57096398845 to your computer and use it in GitHub Desktop.
Propuestas Partidos políticos según newtral
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