Skip to content

Instantly share code, notes, and snippets.

@snakewiz
Created March 18, 2021 01:15
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 snakewiz/b37a18e92cc0b112ce0fa57b1096b96b to your computer and use it in GitHub Desktop.
Save snakewiz/b37a18e92cc0b112ce0fa57b1096b96b to your computer and use it in GitHub Desktop.
Script to scrape ped list from FiveM docs.
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