30 lines
1.2 KiB
C++
30 lines
1.2 KiB
C++
#include "restaurants.hpp"
|
|
#include "../network/network.hpp"
|
|
#include "../htmlparser.hpp"
|
|
|
|
void LunchRest::PadagaliRestaurant::parse() {
|
|
int menu_index = 0;
|
|
Request r;
|
|
auto html = r.get(_url);
|
|
if(html == "")
|
|
return;
|
|
clearMenus();
|
|
HtmlParser hparse(html);
|
|
auto &root = hparse.getRoot();
|
|
auto days = root.find("//div[@class='glf-mor-restaurant-menu-category']");
|
|
for(int i = 0; i < 5; i++) {
|
|
auto day = days[i];
|
|
auto meals = day->find("./div");
|
|
for(auto &meal : meals) {
|
|
auto info = meal->find("./div/div/div");
|
|
std::string desc = dynamic_cast<const xmlpp::ContentNode *>(info[1]->find("./text()")[0])->get_content();
|
|
std::string name = dynamic_cast<const xmlpp::ContentNode *>(info[0]->find("./h5/text()")[0])->get_content();
|
|
int price = std::stoi(dynamic_cast<const xmlpp::ContentNode *>(info[0]->find("./div/text()")[0])->get_content());
|
|
bool soup = name.find("Soup") == std::string::npos ? false : true;
|
|
menus[menu_index].addMeal(soup, name, desc, price);
|
|
menus[menu_index].setInvalidMenu(false);
|
|
}
|
|
menu_index++;
|
|
}
|
|
}
|