hop
This commit is contained in:
parent
abd22a4b2a
commit
6d19804851
6
.idea/jsLibraryMappings.xml
Normal file
6
.idea/jsLibraryMappings.xml
Normal 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
@ -5,6 +5,10 @@ import rp from "request-promise";
|
|||||||
|
|
||||||
import $ from "cheerio";
|
import $ from "cheerio";
|
||||||
|
|
||||||
|
import fs from "fs";
|
||||||
|
import path from 'path';
|
||||||
|
const __dirname = path.resolve();
|
||||||
|
|
||||||
function getRandomWikiOSMPage() {
|
function getRandomWikiOSMPage() {
|
||||||
|
|
||||||
// get all FR tags
|
// 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
|
// prendre une ligne de tableau au hasard correspondant à l'ID de la section
|
||||||
const titleSelector = ""
|
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!
|
//success!
|
||||||
const wikiUrls = [];
|
const wikiUrls = [];
|
||||||
const listOfLinks = $(titleLink, html)
|
const listOfLinks = $(titleLink, html)
|
||||||
@ -56,20 +66,18 @@ export default function getElementCartographique(){
|
|||||||
const selectedTocLink = getRandomElementOfArray(listOfLinks).attribs.href;
|
const selectedTocLink = getRandomElementOfArray(listOfLinks).attribs.href;
|
||||||
console.log("selectedTocLink", selectedTocLink)
|
console.log("selectedTocLink", selectedTocLink)
|
||||||
|
|
||||||
const tableRow = getRandomElementOfArray($(`${selectedTocLink}`, html).parent('table').children('tr'))
|
const tableRow = getRandomElementOfArray($(`${selectedTocLink}`, html)).parents('.wikitable')
|
||||||
const tableCells = $('td', tableRow)
|
console.log("tableRow.length", tableRow.length)
|
||||||
console.log("tag key value", tableCells[1])
|
// const tableCells = $('td', tableRow)
|
||||||
console.log("Description", tableCells[3])
|
// console.log("tableRow.length", tableRow.length)
|
||||||
console.log("icone", tableCells[4])
|
// console.log("tag key value", tableCells[1])
|
||||||
console.log("photo", tableCells[5])
|
// console.log("Description", tableCells[3])
|
||||||
|
// console.log("icone", tableCells[4])
|
||||||
|
// console.log("photo", tableCells[5])
|
||||||
|
|
||||||
return tableRow;
|
return tableRow;
|
||||||
})
|
|
||||||
.catch(function(err){
|
|
||||||
//handle error
|
|
||||||
console.error(err)
|
|
||||||
});
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user