Upload files to "/"
This commit is contained in:
parent
2ebe533e82
commit
1b1241c306
|
@ -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",
|
||||
|
|
14
server.js
14
server.js
|
@ -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
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue