Skip to content

Instantly share code, notes, and snippets.

@joewright
Last active November 22, 2020 17:31
Show Gist options
  • Save joewright/1bcc533d6248ad7a7d00f71ddd474ce7 to your computer and use it in GitHub Desktop.
Save joewright/1bcc533d6248ad7a7d00f71ddd474ce7 to your computer and use it in GitHub Desktop.
grocery list scraper
const itemClass = 'title clamp-2';
printItems();
function printItems() {
const items = document.getElementsByClassName(itemClass);
const uniq = [];
let output = '';
for (let item of items) {
const trimmed = String(item.innerText).trim();
if (!uniq.includes(trimmed)) {
uniq.push(trimmed);
output += `${trimmed}\n`;
}
}
return output;
}
@joewright
Copy link
Author

joewright commented Oct 13, 2019

This grabs a text list of grocery cart items on the Publix website. I use it to dump the text into a checklist app like google keep.

Add stuff to your cart, go to your shopping list, click on Print, paste the above into your browser console.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment