la pagina de sunat .gob.pe tiene archivos que se descargan con la extension .exe y .rar , asi es que le agregue esas extensiones y cachea todas las descargas de esta pagina
http://www2.sunat.gob.pe/
#include <iostream>
#include <cstring>
#include <vector>
#include "../utils.cpp"
// use this line to compile
// g++ -I. -fPIC -shared -g -o sunat.gob.pe.so sunat.gob.pe.cpp
// regex
// http.*\.sunat\.gob\.pe.*(\.gif|\.jpg|\.png|\.exe|\.rar|\.zip|\.swf)
string get_filename(string url) {
vector<string> resultado;
if (url.find("?") != string::npos) {
stringexplode(url, "?", &resultado);
stringexplode(resultado.at(resultado.size()-2), "/", &resultado);
return resultado.at(resultado.size()-1);
} else {
stringexplode(url, "/", &resultado);
return resultado.at(resultado.size()-1);
}
}
extern "C" resposta getmatch(const string url) {
resposta r;
if ( (url.find(".sunat.gob.pe") != string::npos)
) {
r.file = get_filename(url);
if (!r.file.empty()) {
r.match = true;
r.domain = "Sunat";
} else {
r.match = false;
}
} else {
r.match = false;
}
return r;
}
amigo david_domh con code le quedaran mucho mas presentables sus plugins, code es el numeral o lo puede hacer con code=cpp, para abrir y /code, para cerrar que dandole asi:
#include <iostream>
#include <cstring>
#include <vector>
#include "../utils.cpp"
// use this line to compile
// g++ -I. -fPIC -shared -g -o sunat.gob.pe.so sunat.gob.pe.cpp
// regex
// http.*\.sunat\.gob\.pe.*(\.gif|\.jpg|\.png|\.exe|\.rar|\.zip|\.swf)
string get_filename(string url) {
vector<string> resultado;
if (url.find("?") != string::npos) {
stringexplode(url, "?", &resultado);
stringexplode(resultado.at(resultado.size()-2), "/", &resultado);
return resultado.at(resultado.size()-1);
} else {
stringexplode(url, "/", &resultado);
return resultado.at(resultado.size()-1);
}
}
extern "C" resposta getmatch(const string url) {
resposta r;
if ( (url.find(".sunat.gob.pe") != string::npos)
) {
r.file = get_filename(url);
if (!r.file.empty()) {
r.match = true;
r.domain = "Sunat";
} else {
r.match = false;
}
} else {
r.match = false;
}
return r;
}
Saludos
Gracias por la sugerencia Firecold