Remove COUT and formatting
This commit is contained in:
parent
4d7586168e
commit
a635d7673a
@ -18,7 +18,6 @@ void LunchRest::SuziesRestaurant::parse() {
|
||||
HtmlParser hparse(html);
|
||||
auto &root = hparse.getRoot();
|
||||
auto days = root.find("//div[@class='uk-card-body item']");
|
||||
std::cout << "IMMA TRY" << std::endl;
|
||||
for (auto &day : days) {
|
||||
auto daytext = nodeToText(day->find("./h2/text()")[0]);
|
||||
int cur_day = 0;
|
||||
@ -39,15 +38,13 @@ void LunchRest::SuziesRestaurant::parse() {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
std::cout << "DAY: " << cur_day << std::endl;
|
||||
bool working_on_meal = false;
|
||||
bool working_on_soup = false;
|
||||
Meal meal{};
|
||||
for (auto &child : day->get_children()) {
|
||||
if(child->get_name() == "h3" && child->find("./text()").size() != 0) {
|
||||
std::cout << "MEAL" << std::endl;
|
||||
if (child->get_name() == "h3" &&
|
||||
child->find("./text()").size() != 0) {
|
||||
auto meal_type = trim(nodeToText(child->find("./text()")[0]));
|
||||
std::cout << meal_type << std::endl;
|
||||
meal = Meal();
|
||||
working_on_meal = true;
|
||||
if (meal_type == "Polévka") {
|
||||
@ -59,25 +56,36 @@ void LunchRest::SuziesRestaurant::parse() {
|
||||
}
|
||||
if (working_on_meal && child->get_name() == "div") {
|
||||
if (!working_on_soup) {
|
||||
auto price_elements = child->find("./div[contains(@class, 'price')]/text()");
|
||||
auto price_elements =
|
||||
child->find("./div[contains(@class, 'price')]/text()");
|
||||
if (price_elements.size() == 0) {
|
||||
goto end;
|
||||
}
|
||||
auto price = nodeToText(price_elements[0]);
|
||||
std::cout << "PRICE: " << price << std::endl;
|
||||
meal.setPrice(std::stoi(price));
|
||||
auto namelen = child->find("./div[contains(@class, 'uk-width-expand')]/text()").size();
|
||||
auto namelen = child
|
||||
->find("./div[contains(@class, "
|
||||
"'uk-width-expand')]/text()")
|
||||
.size();
|
||||
std::string name = "";
|
||||
if (namelen == 1) {
|
||||
name = trim(nodeToText(child->find("./div[contains(@class, 'uk-width-expand')]/text()")[0]));
|
||||
name = trim(nodeToText(child->find(
|
||||
"./div[contains(@class, 'uk-width-expand')]/text()")
|
||||
[0]));
|
||||
} else {
|
||||
name = trim(nodeToText(child->find("./div[contains(@class, 'uk-width-expand')]/span/text()")[0])) + " " + trim(nodeToText(child->find("./div[contains(@class, 'uk-width-expand')]/text()")[1]));
|
||||
name = trim(nodeToText(child->find(
|
||||
"./div[contains(@class, "
|
||||
"'uk-width-expand')]/span/text()")[0])) +
|
||||
" " +
|
||||
trim(nodeToText(child->find(
|
||||
"./div[contains(@class, "
|
||||
"'uk-width-expand')]/text()")[1]));
|
||||
}
|
||||
std::cout << name << std::endl;
|
||||
meal.setName(name);
|
||||
} else {
|
||||
auto name = trim(nodeToText(child->find("./div[contains(@class, 'uk-width-expand')]/text()")[0]));
|
||||
std::cout << name << std::endl;
|
||||
auto name = trim(nodeToText(child->find(
|
||||
"./div[contains(@class, 'uk-width-expand')]/text()")
|
||||
[0]));
|
||||
meal.setName(name);
|
||||
}
|
||||
menus[cur_day].addMeal(meal);
|
||||
|
Loading…
Reference in New Issue
Block a user