2020-09-15 15:25:27 +00:00
|
|
|
#include "restaurants.hpp"
|
2020-09-14 22:55:03 +00:00
|
|
|
#include "../network/network.hpp"
|
|
|
|
#include "../htmlparser.hpp"
|
|
|
|
|
2020-09-15 15:25:27 +00:00
|
|
|
void LunchRest::UKarlaRestaurant::parse() {
|
2020-09-15 14:05:16 +00:00
|
|
|
int menu_index = 0;
|
2020-09-14 22:55:03 +00:00
|
|
|
Request r;
|
|
|
|
auto html = r.get(_url);
|
2020-09-15 14:05:16 +00:00
|
|
|
if(html == "")
|
|
|
|
return;
|
2020-09-15 21:04:16 +00:00
|
|
|
clearMenus();
|
2020-09-14 22:55:03 +00:00
|
|
|
HtmlParser hparse(html);
|
|
|
|
auto &root = hparse.getRoot();
|
|
|
|
auto days = root.find("//li[@class='item-day']");
|
|
|
|
int validdays = 0;
|
|
|
|
for(auto &day : days) {
|
|
|
|
validdays++;
|
|
|
|
auto meals = day->find("./div[@class='row']");
|
|
|
|
for(auto &meal : meals) {
|
|
|
|
auto soup = false;
|
|
|
|
auto texts = meal->find("./div/text()");
|
2021-02-09 22:23:37 +00:00
|
|
|
std::string name = trim(nodeToText(texts[0]));
|
2020-09-14 22:55:03 +00:00
|
|
|
if(name[0] == 'P') {
|
|
|
|
soup = true;
|
|
|
|
name = name.substr(10);
|
2020-09-15 15:25:27 +00:00
|
|
|
} else {
|
|
|
|
name = name.substr(3);
|
2020-09-14 22:55:03 +00:00
|
|
|
}
|
|
|
|
int price = -1;
|
|
|
|
if(texts.size() > 1)
|
2021-02-09 22:23:37 +00:00
|
|
|
price = std::stoi(trim(nodeToText(texts[1])));
|
2020-09-15 14:05:16 +00:00
|
|
|
menus[menu_index].addMeal(soup, name, "", price);
|
|
|
|
menus[menu_index].setInvalidMenu(false);
|
2020-09-14 22:55:03 +00:00
|
|
|
}
|
2020-09-15 14:05:16 +00:00
|
|
|
menu_index++;
|
2020-09-14 22:55:03 +00:00
|
|
|
}
|
|
|
|
}
|