Skip to content

Instantly share code, notes, and snippets.

@ThomasG77
Created October 24, 2019 01:08
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 ThomasG77/aef047eb7b597127e5e0a6aed67ca58b to your computer and use it in GitHub Desktop.
Save ThomasG77/aef047eb7b597127e5e0a6aed67ca58b to your computer and use it in GitHub Desktop.
Import pour scrapper parcs et jardins de Nantes
node_modules/
package-lock.json
const fs = require('fs');
const puppeteer = require('puppeteer-core');
(async () => {
const browser = await puppeteer.launch({
executablePath: '/snap/bin/chromium'//'/usr/bin/google-chrome'
});
const page = await browser.newPage();
await page.goto('https://jardins.nantes.fr/N/Jardin/Parcs-Jardins/Carte/Carte-Jardin-Tous.asp', {
timeout: 3000000
});
// Récupération des parcs
const geojson = await page.evaluate(() => {
return window.locations.reduce(function(acc, curr) {
acc.features.push({
"type": "Feature",
"properties": {
libellepoint: curr[0],
codepoint: curr[3],
surfacepoint: curr[4]
},
"geometry": {
"type": "Point",
"coordinates": [
curr[2],
curr[1]
]
}
})
return acc;
}, {
"type": "FeatureCollection",
"features": []
})
});
console.log('Geojson:', geojson);
fs.writeFileSync('parcs-jardin-nantes.geojson', JSON.stringify(geojson, null, ' '), {
encoding: 'utf-8'
});
await browser.close();
})();
{
"name": "scrapping-parcs-jardins-nantes",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"puppeteer-core": "^1.20.0"
}
}
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment