diff --git a/server/miastamaszerujace.ts b/server/miastamaszerujace.ts index e76256f5d..0867eab2c 100644 --- a/server/miastamaszerujace.ts +++ b/server/miastamaszerujace.ts @@ -20,15 +20,20 @@ const year = Day.today().year; const fetchEvents = async (): Promise => { const events: MiastamaszerujaceEvent[] = []; + // issue with third-party cert: Verification error: unable to verify the first certificate + // browser and curl accepts the certificate, but node seems more picky + process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; const html = await (await fetch('https://miastamaszerujace.pl/')).text(); const dom = new JSDOM(html // manual fixes for irregular HTML .replace(new RegExp('ref=newsfeed
', 'g'), '

') .replace(new RegExp('(.*?)', 'g'), '$1')); - const eventsImgs = dom.window.document.querySelectorAll('img[src="https://miastamaszerujace.pl/wp-content/uploads/2021/11/Zasob-6@4x.png"]'); - for (const eventImg of eventsImgs) { - const p = eventImg.closest('p')!; - if (p.textContent!.includes('Daty kolejnych') || p.textContent!.includes('Marsz organizowany przez grupę współpracującą')) { + const eventNodes = dom.window.document.querySelectorAll('[data-id="d4c3075"] p'); + for (const p of eventNodes) { + if (p.textContent!.includes('Daty kolejnych') || + p.textContent!.includes('Marsz organizowany przez grupę współpracującą') || + p.textContent!.includes('Opublikowane do tej pory') + ) { continue; } @@ -39,7 +44,9 @@ const fetchEvents = async (): Promise => { .filter((c) => c.nodeType === 3 /* text node */ || c.nodeName === 'A') .map((c) => c.textContent!.trim()) .filter((t) => !!t) - .join(' '); + .join(' ') + .replace(/^– /, '') + ; let link = null; try {