make an osm message

This commit is contained in:
Tykayn 2022-08-05 15:19:45 +02:00 committed by tykayn
parent 70e4dce6ea
commit 0beaf1146d

View File

@ -48,7 +48,7 @@ export default function getElementCartographique() {
const titleSelector = "" const titleSelector = ""
fs.readFile(__dirname + '/assets/documents/elements_carto_osm.html', 'utf8', function (err, html) { return fs.readFile(__dirname + '/assets/documents/elements_carto_osm.html', 'utf8', function (err, html) {
if (err) { if (err) {
return console.log(err); return console.log(err);
} }
@ -121,12 +121,23 @@ export default function getElementCartographique() {
// aller chercher le lien // aller chercher le lien
// image de description: // image de description:
let imgSelector = ".description a.image img" let imgSelector = ".description a.image img"
const message = makePostMessageFromObj(result)
console.log("message", message)
return result; return result;
}); });
} }
function makePostMessageFromObj(result) {
return `
# [Le tag OSM du jour : ${result.key}=${result.value}](${result.link})
> ${result.description.trim()}
#osm #openstreetmap #wiki #rtfw
`
}
function getQuery() { function getQuery() {
// var url = "https://wiki.openstreetmap.org/w/api.php"; // var url = "https://wiki.openstreetmap.org/w/api.php";
var url = "https://fr.wikipedia.org/w/api.php"; var url = "https://fr.wikipedia.org/w/api.php";
@ -166,3 +177,9 @@ function getQuery() {
} }
// run
const res = getElementCartographique()
console.log("res", res)