settings and bugfixes

This commit is contained in:
2025-03-23 20:55:34 +03:00
parent e58d6068e0
commit d17695a7fa
14 changed files with 487 additions and 395 deletions

View File

@@ -145,16 +145,16 @@ std::vector<std::wstring> find_in_html(std::string& html, std::string regex, std
it != end; it++) {
std::wstring found_entry = from_utf8(it->str());
std::wcout << "Found: " << found_entry << std::endl;
std::cout << "Found: " << to_utf8(found_entry) << std::endl;
std::wstring extracted = substring_from_to(found_entry, from_utf8(html_start), from_utf8(html_end));
std::wcout << "Extracted: " << extracted << std::endl;
std::cout << "Extracted: " << to_utf8(extracted) << std::endl;
parsed.push_back(extracted);
}
return parsed;
}
std::vector<std::wstring> find_products_in_html(std::string html) {
return find_in_html(html, "<div class=\"ifw-col ifw-col-1 text-left\"><b>.{10,100}<\\/b><\\/div>", "<div class=\"ifw-col ifw-col-1 text-left\"><b>", "<\\/b><\\/div>");
return find_in_html(html, "<div class=\"ifw-col ifw-col-1 text-left\"><b>.{2,100}<\\/b><\\/div>", "<div class=\"ifw-col ifw-col-1 text-left\"><b>", "<\\/b><\\/div>");
}
std::vector<std::wstring> find_amounts_in_html(std::string html) {
@@ -170,11 +170,16 @@ std::vector<std::wstring> find_net_weights_in_names(std::vector<std::wstring> &n
std::vector<std::wstring> result;
for (std::wstring &name : names ) {
boost::wregex regexp(from_utf8("((\\d+(.|,)?\\d?((м|)л|(к|м|)г|т|ц|шт|(pc|)s|(m|k|)g|(m|)l|t)).?)+"), boost::regex_constants::collate);
bool found = false;
for (boost::wsregex_iterator it{name.begin(), name.end(), regexp}, end{}; it != end;
it++) {
result.push_back(it->str());
found = true;
break;
}
if (!found) {
result.push_back(from_utf8("?"));
}
}
return result;
}
@@ -247,6 +252,8 @@ Check parseOfdRuAnswer(std::string html) {
Check c;
for (int i = 0; i < products.size(); i ++) {
std::cout << "Adding to check: ";
std::cout << to_utf8(products[i]) << " " << to_utf8(prices[i]) << " " << to_utf8(net_weights[i]) << " " << to_utf8(amounts[i]) << std::endl;
Goods goods(to_utf8(products[i]), std::stod(prices[i]), to_utf8(net_weights[i]), std::stod(amounts[i]));
c.add_goods(goods);
}