This commit is contained in:
Tykayn 2022-08-04 16:30:18 +02:00 committed by tykayn
parent abd22a4b2a
commit 6d19804851
3 changed files with 58460 additions and 17746 deletions

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptLibraryMappings">
<includedPredefinedLibrary name="Node.js Core" />
</component>
</project>

File diff suppressed because one or more lines are too long

View File

@ -5,6 +5,10 @@ import rp from "request-promise";
import $ from "cheerio";
import fs from "fs";
import path from 'path';
const __dirname = path.resolve();
function getRandomWikiOSMPage() {
// get all FR tags
@ -47,8 +51,14 @@ export default function getElementCartographique(){
// prendre une ligne de tableau au hasard correspondant à l'ID de la section
const titleSelector = ""
rp(url)
.then(function(html){
fs.readFile( __dirname + '/assets/documents/elements_carto_osm.html', 'utf8', function (err, html) {
if (err) {
return console.log(err);
}
// console.log(data);
//success!
const wikiUrls = [];
const listOfLinks = $(titleLink, html)
@ -56,20 +66,18 @@ export default function getElementCartographique(){
const selectedTocLink = getRandomElementOfArray(listOfLinks).attribs.href;
console.log("selectedTocLink", selectedTocLink)
const tableRow = getRandomElementOfArray($(`${selectedTocLink}`, html).parent('table').children('tr'))
const tableCells = $('td', tableRow)
console.log("tag key value", tableCells[1])
console.log("Description", tableCells[3])
console.log("icone", tableCells[4])
console.log("photo", tableCells[5])
const tableRow = getRandomElementOfArray($(`${selectedTocLink}`, html)).parents('.wikitable')
console.log("tableRow.length", tableRow.length)
// const tableCells = $('td', tableRow)
// console.log("tableRow.length", tableRow.length)
// console.log("tag key value", tableCells[1])
// console.log("Description", tableCells[3])
// console.log("icone", tableCells[4])
// console.log("photo", tableCells[5])
return tableRow;
})
.catch(function(err){
//handle error
console.error(err)
});
});
}