Fix PLAC
This commit is contained in:
parent
560cd28e78
commit
bcb6120199
2
main.cpp
2
main.cpp
@ -99,7 +99,7 @@ int main(int argc, char **argv, char **env) {
|
||||
restaurants["lightofindia"] = std::make_unique<LunchRest::LightOfIndiaRestaurant>();
|
||||
restaurants["ukarla"] = std::make_unique<LunchRest::UKarlaRestaurant>();
|
||||
restaurants["alcapone"] = std::make_unique<LunchRest::AlCaponeRestaurant>();
|
||||
// restaurants["plac"] = std::make_unique<LunchRest::PlacRestaurant>();
|
||||
restaurants["plac"] = std::make_unique<LunchRest::PlacRestaurant>();
|
||||
restaurants["zo"] = std::make_unique<LunchRest::ZoRestaurant>();
|
||||
// restaurants["suzzies"] = std::make_unique<LunchRest::SuzziesRestaurant>();
|
||||
std::cout << "Initial parsing" << std::endl;
|
||||
|
@ -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 <iostream>
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user