0
0
mirror of https://github.com/Maks1mS/free-ozon-dpr.git synced 2024-12-24 10:54:38 +03:00
free-ozon-dpr/scripts/update.js

50 lines
1.1 KiB
JavaScript
Raw Normal View History

2024-06-05 14:56:19 +03:00
import fs from "node:fs/promises";
import { asyncMap } from "modern-async";
import { getFinalURL } from "./utils.js";
2024-06-06 19:38:01 +03:00
import ozonWbDpr from "./update/ozon-wb-dpr.js";
2024-06-06 20:31:02 +03:00
import sevenDostavka from "./update/sevenDostavka.js";
2024-06-05 14:56:19 +03:00
async function woyag() {
const apiResponse = await fetch("https://login.woyag.ru/ajax/pvz-list");
const json = await apiResponse.json();
let points = json.filter((point) => !!point.link);
points = await asyncMap(points, async (point) => {
const link = await getFinalURL(point.link).then(u => {
const final = new URL(u);
final.search = '';
return final.toString();
})
return {
coordinates: [parseFloat(point["geo_lng"]), parseFloat(point["geo_lat"])],
name: point.name,
2024-06-06 17:19:54 +03:00
address: point.address,
2024-06-05 14:56:19 +03:00
link,
operationTime: "пн-вс с 9:00 до 17:45",
};
});
await fs.writeFile(
"data/01_woyag.json",
JSON.stringify(
{
name: "WOЯЖ",
source: "https://login.woyag.ru/map",
points,
},
undefined,
4
)
);
}
async function main() {
2024-06-06 20:54:27 +03:00
await woyag();
2024-06-05 14:56:19 +03:00
await sevenDostavka();
2024-06-06 20:54:27 +03:00
await ozonWbDpr();
2024-06-05 14:56:19 +03:00
}
main();