do not search for other element if found an existing wiki page

This commit is contained in:
Tykayn 2022-08-08 18:34:56 +02:00 committed by tykayn
parent 948fb0cb82
commit 9eb196aaa5
1 changed files with 19 additions and 4 deletions

View File

@ -19,8 +19,9 @@ const __dirname = path.resolve();
const selectionOverrideOfSectionTable = '';
const selectionOverrideOfLineTable = '';
// const reallySendToot = false;
const reallySendToot = false;
let foundExistingWikiPageInFrench = false;
// const reallySendToot = true;
const reallySendPost = false;
function getRandomWikiOSMPage() {
@ -53,6 +54,10 @@ function getRandomWikiOSMPage() {
}
export default function getElementCartographique() {
if(foundExistingWikiPageInFrench){
console.log("already found foundExistingWikiPageInFrench")
return;
}
const url = "https://wiki.openstreetmap.org/wiki/FR:%C3%89l%C3%A9ments_cartographiques"
const titleLink = "#toc a"
const listElementSelector = "#toc a"
@ -129,6 +134,7 @@ export default function getElementCartographique() {
console.error("ERROR no key found", $(cells).html())
console.error('no key BOOOOOOOOOOH');
getElementCartographique();
return;
}
// aller chercher le lien
@ -144,7 +150,7 @@ export default function getElementCartographique() {
// get a random page wich is not a discussion
// certaines valeurs ont des espaces, donc pas utilisable en url
if (configPost.value.indexOf(' ') === -1) {
if (configPost.value.indexOf(' ') === -1 || configPost.value.indexOf('<') === -1 || configPost.value.indexOf('>') === -1) {
console.log("url", url)
rp(url).then(function (html) {
@ -159,7 +165,9 @@ export default function getElementCartographique() {
// image de description:
// let imgSelector = ".description a.image img"
console.log("✅ cette page existe bien en Français sur le wiki OSM")
foundExistingWikiPageInFrench = true;
sendMessageWikiTagOfTheDay(makePostMessageFromObj(configPost))
return;
}, (err) => {
console.error(err.statusCode)
@ -174,6 +182,7 @@ export default function getElementCartographique() {
});
console.log("bon spa tout ça on essaie une autre ligne")
getElementCartographique()
return;
}
})
@ -204,6 +213,10 @@ export default function getElementCartographique() {
* @returns {*}
*/
function checkExistenceOfWebPage(url) {
if(foundExistingWikiPageInFrench){
console.log("already found foundExistingWikiPageInFrench, no need to check other page", url)
return;
}
return rp(url).then((html) => {
console.log("oui cette page existe!", url)
}, (err) => {
@ -268,12 +281,14 @@ const res = getElementCartographique()
function sendMessageWikiTagOfTheDay(message) {
let configPost = {
author: 'curator',
image: 'osm_default.jpg',
message,
// reallySendPost: true,
reallySendPost: reallySendToot,
reallySendPost: reallySendPost,
}
sendPostMastodon(configPost)
}