Upload files to "/"

This commit is contained in:
daniele 2025-06-24 11:17:53 +00:00
parent 2ebe533e82
commit 1b1241c306
2 changed files with 16 additions and 6 deletions

View File

@ -1,14 +1,14 @@
{
"name": "start-fermate",
"version": "1.0.0",
"name": "start-fermate-api",
"version": "2.0.0",
"main": "script.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"author": "IlDani - Curry141",
"license": "MIT",
"description": "",
"dependencies": {
"axios": "^1.10.0",

View File

@ -15,12 +15,16 @@ app.get('/', async (req, res) => {
const response = await axios.get(url);
const $ = cheerio.load(response.data);
const results = [];
const fermata = $('h2.fw-bold.text-primary.title').text().trim();
results.push({
fermata
});
$('.container.mb-50 .bus-card').each((i, el) => {
const element = $(el);
const isSoppressa = element.find('.bus-status.sopp').length > 0;
const headerSpan = element.find('.bus-header span').first();
const orario = element.find('.bus-times span').first().text().trim();
var stato = element.find('.bus-status').text().trim();
var linea = headerSpan.contents().filter((i, el) => el.type === 'text').text().trim();
const destinazione = element.find('.bus-destination').text().trim();
var mezzo = element.find('.det a').attr('data-vehicle') || '';
@ -29,6 +33,10 @@ app.get('/', async (req, res) => {
mezzo = 3 + mezzo;
}
if(stato == "Non disp"){
stato = "Non disponibile";
}
if(mezzo == ""){
mezzo = "Non disponibile";
}
@ -49,6 +57,8 @@ app.get('/', async (req, res) => {
results.push({
linea,
destinazione,
orario,
stato,
mezzo,
soppressa: isSoppressa
});