From cdba0bfa16a11e9332bbcfa11b8b21b13c433ddc Mon Sep 17 00:00:00 2001 From: Maxim Slipenko Date: Sat, 22 Jun 2024 23:16:49 +0300 Subject: [PATCH] fix globalExpress newline --- data/02_global-express.json | 4 ++-- merged-data.json | 4 ++-- package-lock.json | 17 ++++++++++++++--- package.json | 1 + scripts/update/globalExpress.js | 9 +++++---- 5 files changed, 24 insertions(+), 11 deletions(-) diff --git a/data/02_global-express.json b/data/02_global-express.json index 5ec1953..98bd530 100644 --- a/data/02_global-express.json +++ b/data/02_global-express.json @@ -28,8 +28,8 @@ 47.959707 ], "link": "https://ozon.ru/point/534953", - "name": "г. Донецк, пр - кт Ленинский, 98Аостановка «Звездный»", - "address": "г. Донецк, пр - кт Ленинский, 98Аостановка «Звездный»", + "name": "г. Донецк, пр - кт Ленинский, 98А остановка «Звездный»", + "address": "г. Донецк, пр - кт Ленинский, 98А остановка «Звездный»", "operationTime": "ГРАФИК РАБОТЫ" }, { diff --git a/merged-data.json b/merged-data.json index c9df73a..b597ea9 100644 --- a/merged-data.json +++ b/merged-data.json @@ -353,8 +353,8 @@ 37.775896, 47.959707 ], - "name": "г. Донецк, пр - кт Ленинский, 98Аостановка «Звездный»", - "address": "г. Донецк, пр - кт Ленинский, 98Аостановка «Звездный»", + "name": "г. Донецк, пр - кт Ленинский, 98А остановка «Звездный»", + "address": "г. Донецк, пр - кт Ленинский, 98А остановка «Звездный»", "operationTime": "ГРАФИК РАБОТЫ", "source": "https://t.me/Mariupol_global_express/1977", "provider": "Global Express" diff --git a/package-lock.json b/package-lock.json index d01673e..a069d49 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,6 +19,7 @@ }, "devDependencies": { "@eslint/js": "^9.4.0", + "collapse-white-space": "^2.1.0", "eslint": "^9.4.0", "globals": "^15.4.0", "vite": "^5.2.0", @@ -1093,6 +1094,16 @@ "wrap-ansi": "^6.2.0" } }, + "node_modules/collapse-white-space": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/collapse-white-space/-/collapse-white-space-2.1.0.tgz", + "integrity": "sha512-loKTxY1zCOuG4j9f6EPnuyyYkf58RnhhWTvRoZEokgB+WbdXehfjFviyOVYkqzEWz1Q5kRiZdBYS5SwxbQYwzw==", + "dev": true, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -3238,9 +3249,9 @@ "dev": true }, "node_modules/ws": { - "version": "8.17.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.0.tgz", - "integrity": "sha512-uJq6108EgZMAl20KagGkzCKfMEjxmKvZHG7Tlq0Z6nOky7YF7aq4mOx6xK8TJ/i1LeK4Qus7INktacctDgY8Ow==", + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz", + "integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==", "engines": { "node": ">=10.0.0" }, diff --git a/package.json b/package.json index f62c61a..2886d5f 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ }, "devDependencies": { "@eslint/js": "^9.4.0", + "collapse-white-space": "^2.1.0", "eslint": "^9.4.0", "globals": "^15.4.0", "vite": "^5.2.0", diff --git a/scripts/update/globalExpress.js b/scripts/update/globalExpress.js index ef04766..e80e122 100644 --- a/scripts/update/globalExpress.js +++ b/scripts/update/globalExpress.js @@ -3,6 +3,7 @@ import fs from "node:fs/promises"; import { JSDOM } from "jsdom"; import { asyncMap } from "modern-async"; import { getTelegramMessage } from "../utils.js"; +import { collapseWhiteSpace } from "collapse-white-space"; const OUTPUT_FILE = "data/02_global-express.json"; const MAIN_URL = "https://t.me/Mariupol_global_express/1977"; @@ -127,8 +128,9 @@ async function getFromTelegram() { } const data = await asyncMap(links, async (link) => { - const textContent = link.textContent; - + const textContent = collapseWhiteSpace( + link.innerHTML.replace(//gi, " ") + ); const pvzData = await getPVZFromPost(link.href); return { @@ -177,8 +179,7 @@ async function globalExpress() { source: MAIN_URL, points: points.map((p) => ({ ...p, - operationTime: - `ГРАФИК РАБОТЫ`, + operationTime: `ГРАФИК РАБОТЫ`, })), }, undefined,