Skip to content

Instantly share code, notes, and snippets.

@mattdsteele
Created April 23, 2017 19:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattdsteele/89e0c65aba305b707a8f1e5654c0c5be to your computer and use it in GitHub Desktop.
Save mattdsteele/89e0c65aba305b707a8f1e5654c0c5be to your computer and use it in GitHub Desktop.
Screen Scrape Papercall.io

Papercall's free version doesn't have a public API, so this is a stupid simple way to get a pseudo-CSV of all the submissions on a page.

(() => {
let submissions = document.querySelector('.table--stack').querySelectorAll('tbody tr');
const datum = [];
for (const el of submissions) {
const s = {};
const i = el.querySelector('td:first-child');
const url = i.querySelector('a:first-child').getAttribute('href');
const title = i.querySelector('a:first-child strong').textContent.trim();
let author = '';
for (const cn of i.childNodes) {
if (cn.nodeType === 3) {
author += cn.textContent.trim().replace(',','');
}
}
s.title = title;
s.author = author;
s.url = url;
const location = i.querySelector('small');
if (location) {
s.location = location.textContent.trim().replace('/','');
}
datum.push(s);
}
for (const d of datum) {
console.log(`"${d.title}","https://www.papercall.io${d.url}","${d.author}","${d.location}"`);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment