diff options
author | JoelHMikael <53561102+JoelHMikael@users.noreply.github.com> | 2022-01-18 18:57:53 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-18 18:57:53 +0200 |
commit | a259127b9fa0349c73340c882f6525f27f7caaed (patch) | |
tree | ad18984d3031ce6bc7ccb549415c58d77672a53f /scrape.js | |
parent | 8f711465194f6779271825bdb2413658880f4c18 (diff) | |
parent | edf044c1e1e0c751229549dd9d14062b230149be (diff) | |
download | LYLLRuoka-a259127b9fa0349c73340c882f6525f27f7caaed.tar.gz LYLLRuoka-a259127b9fa0349c73340c882f6525f27f7caaed.zip |
Merge pull request #1 from JoelHMikael/MYSQLDB
Mysqldb
Diffstat (limited to 'scrape.js')
-rw-r--r-- | scrape.js | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -1,4 +1,7 @@ -const https = require("https"); const parse = require("./parse.js"); const fs = require("fs"); const events = require("events"); +const https = require("https"); +const parse = require("./DBPARSE.js"); +const fs = require("fs"); +const events = require("events"); async function urlOpen(path) { @@ -22,7 +25,7 @@ async function scrapeFood(url) data = data.toString("utf-8"); let foodList = []; - const weekdays = ["su", "ma", "ti", "ke", "to", "pe", "la"]; + const weekdays = ["ma", "ti", "ke", "to", "pe", "la", "su"]; let titleTags = ["<title>", "</title>"]; let foodTags = ["<![CDATA[", "]]>"]; @@ -49,7 +52,7 @@ async function scrapeFood(url) let weekdayIndex = weekdays.findIndex(val => { return val === title.substring(0, 2); }); if (weekdayIndex !== -1) - foodList[weekdayIndex] = [title, food]; + foodList[weekdayIndex] = [title, neatify(food)]; titleSpan = getSpan(data, titleTags, foodSpan[1]); foodSpan = getSpan(data, foodTags, titleSpan[1]); @@ -63,5 +66,10 @@ function getFoodLink(week) return `https://eruokalista.lohja.fi/AromieMenus/FI/Default/Lohja/Koulut/Rss.aspx?Id=97f76449-f57c-4217-aede-b5f9dbf2b41e&DateMode=${week}`; } +function neatify(food) +{ + return food.replaceAll(")", ")<br>").replaceAll(" :", ":").replaceAll(":", ":<br>"); +} + exports.food = scrapeFood; exports.link = getFoodLink; |