Last active
November 22, 2020 17:31
-
-
Save joewright/1bcc533d6248ad7a7d00f71ddd474ce7 to your computer and use it in GitHub Desktop.
grocery list scraper
This file contains hidden or 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
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.