Padagali added span
This commit is contained in:
parent
cbd45bfce8
commit
f98670dee7
@ -5,13 +5,17 @@
|
||||
int dayToNum(const std::string &day) {
|
||||
if(day.find("POND") != std::string::npos) {
|
||||
return 0;
|
||||
} else if (day.find("ÚTER") != std::string::npos) {
|
||||
}
|
||||
if (day.find("ÚTER") != std::string::npos) {
|
||||
return 1;
|
||||
} else if (day.find("STŘE") != std::string::npos) {
|
||||
}
|
||||
if (day.find("STŘE") != std::string::npos) {
|
||||
return 2;
|
||||
} else if (day.find("ČTVR") != std::string::npos) {
|
||||
}
|
||||
if (day.find("ČTVR") != std::string::npos) {
|
||||
return 3;
|
||||
} else if (day.find("PÁTE") != std::string::npos) {
|
||||
}
|
||||
if (day.find("PÁTE") != std::string::npos) {
|
||||
return 4;
|
||||
}
|
||||
return -1;
|
||||
@ -20,25 +24,27 @@ int dayToNum(const std::string &day) {
|
||||
void LunchRest::PadagaliRestaurant::parse() {
|
||||
Request r;
|
||||
auto html = r.get(_url);
|
||||
if(html == "")
|
||||
if(html.empty()) {
|
||||
return;
|
||||
}
|
||||
clearMenus();
|
||||
HtmlParser hparse(html);
|
||||
auto &root = hparse.getRoot();
|
||||
auto days = root.find("//div[@class='glf-mor-restaurant-menu-category']");
|
||||
auto menu_index = dayToNum(nodeToText(days[0]->find("./h3/text()")[0]));
|
||||
if(menu_index == -1)
|
||||
if(menu_index == -1) {
|
||||
return;
|
||||
}
|
||||
auto max_div = 5 - menu_index;
|
||||
for(int i = 0; i < max_div; i++) {
|
||||
auto day = days[i];
|
||||
auto *day = days[i];
|
||||
auto meals = day->find("./div");
|
||||
for(auto &meal : meals) {
|
||||
auto info = meal->find("./div/div/div");
|
||||
std::string desc = nodeToText(info[1]->find("./text()")[0]);
|
||||
std::string name = nodeToText(info[0]->find("./h5/text()")[0]);
|
||||
int price = std::stoi(nodeToText(info[0]->find("./div/text()")[0]));
|
||||
bool soup = name.find("Soup") == std::string::npos ? false : true;
|
||||
int price = std::stoi(nodeToText(info[0]->find("./div/span/text()")[0]));
|
||||
bool soup = name.find("Soup") != std::string::npos;
|
||||
menus[menu_index].addMeal(soup, name, desc, price);
|
||||
menus[menu_index].setInvalidMenu(false);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user