Last active
April 12, 2020 00:25
-
-
Save Jack5079/1fd46e0dc9592eb66b29c0df7ee89610 to your computer and use it in GitHub Desktop.
get list of raymond lovers (use on https://nookazon.com/product/1096505003)
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 getRaymondHaters = () => new Promise(resolve => { | |
| (function scroll(callback) { | |
| const button = document.querySelector('.see-all-btn-bar > button') | |
| if (button) { | |
| button.scrollIntoView() // so it loads properly for some reason | |
| button.click() // load more | |
| setTimeout(scroll, 300) // account for lag | |
| } else { | |
| // Raymond lovers list is complete | |
| resolve( | |
| Object.fromEntries(Array.from(document.querySelectorAll('tbody tr'), | |
| element => [element.querySelector('.listing-seller-name').innerText, { | |
| bells: element.querySelector('.listing-bells') ? +element.querySelector('.listing-bells').innerText.replace(/,/g, '') : undefined, | |
| contact: element.querySelector('a.listing-seller-contact') ? element.querySelector('a.listing-seller-contact').innerText : undefined, | |
| friendcode: element.querySelector('div.listing-seller-contact') ? element.querySelector('div.listing-seller-contact').innerText : undefined | |
| }] | |
| )) | |
| ) | |
| } | |
| })() | |
| }) | |
| getRaymondHaters().then(console.log) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment