Náhrada deprecated knihovny request na serveru
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import $ from 'cheerio';
|
||||
import rp from 'request-promise';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import axios from 'axios';
|
||||
|
||||
type PizzaSize = {
|
||||
size: string,
|
||||
@@ -41,7 +41,7 @@ const boxPrices: { [key: string]: number } = {
|
||||
*/
|
||||
const downloadPizzy = async () => {
|
||||
// Získáme seznam pizz
|
||||
const html = await rp(pizzyUrl);
|
||||
const html = await axios.get(pizzyUrl).then(res => res.data);
|
||||
const links = $('.vypisproduktu > div > h4 > a', html)
|
||||
const urls = [];
|
||||
for (let i = 0; i < links.length; i++) {
|
||||
@@ -54,7 +54,7 @@ const downloadPizzy = async () => {
|
||||
const result: Pizza[] = [];
|
||||
for (let i = 0; i < urls.length; i++) {
|
||||
const pizzaUrl = urls[i];
|
||||
const pizzaHtml = await rp(pizzaUrl);
|
||||
const pizzaHtml = await axios.get(pizzaUrl).then(res => res.data);
|
||||
// Název
|
||||
const name = $('.produkt > h2', pizzaHtml).first().text()
|
||||
// Přísady
|
||||
|
||||
Reference in New Issue
Block a user