Last active
June 8, 2019 11:26
-
-
Save findscode/b91fbf98710f70ed723df17f5139a1ec to your computer and use it in GitHub Desktop.
Scrap Facebook events via puppeteer.js (no scroll)
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
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