Skip to content

Instantly share code, notes, and snippets.

@findscode
Last active June 8, 2019 11:26
Show Gist options
  • Save findscode/b91fbf98710f70ed723df17f5139a1ec to your computer and use it in GitHub Desktop.
Save findscode/b91fbf98710f70ed723df17f5139a1ec to your computer and use it in GitHub Desktop.
Scrap Facebook events via puppeteer.js (no scroll)
const puppeteer = require("puppeteer");
(async () => {
try {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto("https://www.facebook.com/events/discovery/?suggestion_token=%7B%22city%22%3A%22107677462599905%22%2C%22time%22%3A%22tomorrow%22%7D");
await page.waitForSelector("div.clearfix > div > div > div > div > div > a");
const links = await page.evaluate(() => {
const elements = Array.from(document.querySelectorAll("div.clearfix > div > div > div > div > div > a"));
return elements.map(element => element.href);
});
console.log(links);
browser.close();
} catch (error) {
console.log(error);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment