diff --git a/main.cpp b/main.cpp index 9779407..9e76c67 100644 --- a/main.cpp +++ b/main.cpp @@ -99,7 +99,7 @@ int main(int argc, char **argv, char **env) { restaurants["lightofindia"] = std::make_unique(); restaurants["ukarla"] = std::make_unique(); restaurants["alcapone"] = std::make_unique(); -// restaurants["plac"] = std::make_unique(); + restaurants["plac"] = std::make_unique(); restaurants["zo"] = std::make_unique(); // restaurants["suzzies"] = std::make_unique(); std::cout << "Initial parsing" << std::endl; diff --git a/restaurants/plac.cpp b/restaurants/plac.cpp index c5c1176..e4eeb81 100644 --- a/restaurants/plac.cpp +++ b/restaurants/plac.cpp @@ -1,16 +1,7 @@ #include "restaurants.hpp" #include "../network/network.hpp" #include "../htmlparser.hpp" - -void trim(std::string &str) { - int start = 0; - int end = str.length() - 1; - while(std::isspace(str[start])) - start++; - while(std::isspace(str[end])) - end--; - str = str.substr(start, end - start); -} +#include void LunchRest::PlacRestaurant::parse() { Request r; @@ -23,12 +14,12 @@ void LunchRest::PlacRestaurant::parse() { auto pizzas = root.find("//div[@class='mt-c cf']//div[@class='mt-i cf']"); if(pizzas.size() == 0) return; - auto soups = pizzas[0]; + auto soups = pizzas[0]->find(".//div[@class='b b-text cf']"); - int soup_price = std::stoi(nodeToText(pizzas[1]->find(".//strong/text()")[0])); + int soup_price = std::stoi(nodeToText(soups[1]->find(".//strong/text()")[0])); int cur_day = -1; - for(auto &soup : soups->find(".//text()")) { + for(auto &soup : soups[0]->find(".//p/text()")) { std::string soup_text = nodeToText(soup); auto soup_day = soup_text.substr(0,2); if(soup_day == "Po") @@ -46,15 +37,15 @@ void LunchRest::PlacRestaurant::parse() { } for(unsigned long int i = 2; i < pizzas.size(); i++) { - auto content = pizzas[i]->find(".//div[@class='b-c b-text-c b-s b-s-t60 b-s-b60 cf']"); + auto content = pizzas[i]->find(".//div[@class='b b-text cf']"); auto name_candidates = content[0]->find(".//h3/text()"); std::string name = nodeToText(name_candidates[0]); auto desc_candidates = content[0]->find(".//p//text()"); std::string desc = nodeToText(desc_candidates[0]); auto price_candidates = content[1]->find(".//p/strong/text()"); int price = std::stoi(nodeToText(price_candidates[0])); - trim(name); - trim(desc); + name = trim(name); + desc = trim(desc); addPermanent(false, name, desc, price); } }