Oprava deprecated použití Cheerio

This commit is contained in:
Martin Berka 2023-06-18 18:05:03 +02:00
parent 83e88a641c
commit 0d6020d1a0

View File

@ -1,10 +1,11 @@
import $ from 'cheerio';
import os from 'os';
import path from 'path';
import fs from 'fs';
import axios from 'axios';
import { load } from 'cheerio';
import { formatDate } from './utils';
// TODO přesunout do types
type PizzaSize = {
varId: number,
size: string,
@ -13,6 +14,7 @@ type PizzaSize = {
price: number
}
// TODO přesunout do types
type Pizza = {
name: string,
ingredients: string[],
@ -41,7 +43,8 @@ const boxPrices: { [key: string]: number } = {
const downloadPizzy = async () => {
// Získáme seznam pizz
const html = await axios.get(pizzyUrl).then(res => res.data);
const links = $('.vypisproduktu > div > h4 > a', html)
const $ = load(html);
const links = $('.vypisproduktu > div > h4 > a');
const urls = [];
for (let i = 0; i < links.length; i++) {
if (links[i].name === 'a' && links[i].attribs?.href) {