Oprava deprecated použití Cheerio
This commit is contained in:
parent
83e88a641c
commit
0d6020d1a0
@ -1,10 +1,11 @@
|
|||||||
import $ from 'cheerio';
|
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
import { load } from 'cheerio';
|
||||||
import { formatDate } from './utils';
|
import { formatDate } from './utils';
|
||||||
|
|
||||||
|
// TODO přesunout do types
|
||||||
type PizzaSize = {
|
type PizzaSize = {
|
||||||
varId: number,
|
varId: number,
|
||||||
size: string,
|
size: string,
|
||||||
@ -13,6 +14,7 @@ type PizzaSize = {
|
|||||||
price: number
|
price: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO přesunout do types
|
||||||
type Pizza = {
|
type Pizza = {
|
||||||
name: string,
|
name: string,
|
||||||
ingredients: string[],
|
ingredients: string[],
|
||||||
@ -41,7 +43,8 @@ const boxPrices: { [key: string]: number } = {
|
|||||||
const downloadPizzy = async () => {
|
const downloadPizzy = async () => {
|
||||||
// Získáme seznam pizz
|
// Získáme seznam pizz
|
||||||
const html = await axios.get(pizzyUrl).then(res => res.data);
|
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 = [];
|
const urls = [];
|
||||||
for (let i = 0; i < links.length; i++) {
|
for (let i = 0; i < links.length; i++) {
|
||||||
if (links[i].name === 'a' && links[i].attribs?.href) {
|
if (links[i].name === 'a' && links[i].attribs?.href) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user