Skip to content

Instantly share code, notes, and snippets.

@AndrewStanton94
Created April 9, 2019 09:43
Show Gist options
  • Save AndrewStanton94/d91292814129c4646ebdf22276be29a6 to your computer and use it in GitHub Desktop.
Save AndrewStanton94/d91292814129c4646ebdf22276be29a6 to your computer and use it in GitHub Desktop.
processTable = (table) => {
rows = table.querySelector('tbody').children;
rows = [...rows].map((r) => {
const link = r.children[0].children[0]; // Get the hyperlink from cell 1
let {href, innerText} = link;
innerText = innerText.split(' ').filter((x) => !(['Professor', 'Dr', 'Mr', 'Mrs', 'Miss', 'Ms'].includes(x))).join(' ');
return {href, innerText}
})
output = rows.map(({href, innerText}) => `${innerText} ${href}`).join('\n');
console.log(output);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment