mirror of
https://github.com/Maks1mS/free-ozon-dpr.git
synced 2025-10-21 17:37:30 +03:00
@@ -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));
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
}
|
Reference in New Issue
Block a user