0
0
mirror of https://github.com/Maks1mS/free-ozon-dpr.git synced 2025-10-21 17:37:30 +03:00

Добавлено отображение ID пункта выдачи

Closes #3
This commit is contained in:
2024-06-13 20:30:01 +03:00
parent 5f07385314
commit 41a33e6516
6 changed files with 108 additions and 79 deletions

View File

@@ -1,6 +1,7 @@
import fs from "node:fs/promises";
import { asyncMap } from "modern-async";
import { getDistance } from "ol/sphere.js";
import { extractIDFromURL } from "./utils.js";
function removeDuplicatesByUrl(points) {
const uniquePoints = [];
@@ -64,6 +65,12 @@ async function main() {
data = data.flatMap((v) => v);
data = removeDuplicatesByUrl(data);
data = removeDuplicatesByRadius(data, 10);
// pick all except url
data = data.map(x => {
const { link, ...rest } = x;
return { id: extractIDFromURL(link), ...rest };
});
await fs.writeFile("merged-data.json", JSON.stringify(data, undefined, 2));
}

View File

@@ -63,3 +63,15 @@ export async function getTelegramMessage(input) {
.innerHTML,
};
}
/**
* Извлекает идентификатор пункта выдачи OZON из ссылки
* @param {string} url
*/
export function extractIDFromURL(url) {
const match = url.match(/https:\/\/ozon\.ru\/point\/([0-9]+)/);
if (match) {
return match[1];
}
return null;
}