Last active
June 11, 2019 06:21
-
-
Save Jonasdero/47ee2998a50775f333f8f88381750c8b to your computer and use it in GitHub Desktop.
This file contains 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
function Sleep(milliseconds) { | |
return new Promise(resolve => setTimeout(resolve, milliseconds)); | |
} | |
stories = []; | |
async function getStories() { | |
for (let i = 0; i < 50; i++) { | |
window.scrollTo(0, document.body.scrollHeight); | |
await Sleep(250); | |
} | |
for (let h of document.getElementsByTagName("h3")) { | |
var length = h.childNodes[0].href.split('?')[0].split('/').length | |
stories.push({ | |
url: h.childNodes[0].href.split('?')[0], | |
title: h.childNodes[0].href.split('?')[0].split('/')[length - 1] | |
}); | |
} | |
console.log(JSON.stringify(stories)); | |
} | |
getStories(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment