Skip to content

Instantly share code, notes, and snippets.

@saasindustries
Last active January 14, 2021 15:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saasindustries/e401054a63827afd0b0d99f3055145e8 to your computer and use it in GitHub Desktop.
Save saasindustries/e401054a63827afd0b0d99f3055145e8 to your computer and use it in GitHub Desktop.
let grabPosts = await page.evaluate(() => {
let allPosts = document.body.querySelectorAll('.Post');
// storing the post items in an array then selecting for retrieving content
scrapeItems = [];
allPosts.forEach(item => {
let postTitle = item.querySelector('h3');
let postDescription = item.querySelector('p');
scrapeItems.push({
postTitle: postTitle ? postTitle.innerText : null,
postDescription: postDescription ? postDescription.innerText : null,
});
});
let items = {
"redditPosts": scrapeItems,
};
return items;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment