Created
March 18, 2021 01:15
Script to scrape ped list from FiveM docs.
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"); | |
const fs = require("fs"); | |
async function scrape() { | |
const browser = await puppeteer.launch(); | |
const page = await browser.newPage(); | |
await page.goto("https://docs.fivem.net/docs/game-references/ped-models/"); | |
console.log("Searching for peds ..."); | |
const result = await page.evaluate(() => { | |
const peds = []; | |
document.querySelectorAll("div.model > span > strong").forEach((ped) => { | |
peds.push(ped.innerHTML); | |
}); | |
return peds; | |
}); | |
browser.close(); | |
return result; | |
} | |
scrape().then((peds) => { | |
fs.writeFile("peds.json", JSON.stringify(peds, null, 2), (err) => { | |
if (err) throw err; | |
console.log(`${peds.length} Peds saved`); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment