bonjour,
je voulais savoir si quelqu'un pouvait éventuellement m'apporter son soutien.
Voila deux jour que j'essai de faire une fonction(en c) qui va m'analyser le contenu d'une chaine de caractére pour y récupérer les url.
voici l'idée de base programmé n'importe comment.
do {
const char *str_regex = "href=\"([^\"]*)\"";
err = regcomp (&preg, str_regex, REG_EXTENDED);
if (err != 0)
{
printf("Erreur err = %d\n", err);
}else{
size_t nmatch=5;
regmatch_t *pmatch = NULL;
nmatch = preg.re_nsub;
end = 0;
oldEnd = end;
lengthOfPage = strlen(str_request);
do
{
free(pmatch);
pmatch = malloc (sizeof (*pmatch) * nmatch);
match = regexec (&preg, &str_request[end], nmatch, pmatch, 0);
if (match != 0)
{
printf("Expression non trouvee\n");
}else{
start = pmatch[0].rm_so;
oldEnd = end;
end = pmatch[0].rm_eo;
size = (end-1) - (start+6);
site = malloc (sizeof (*site) * (size + 1));
end+=oldEnd;
if (!site){
printf("Manque de ram?\n");
}else{
strncpy (site, &str_request[oldEnd+start+6], size);
site[size] = '\0';
classUrl(site, urlUsed, domainUrl, domain, urlInDomain);
free (site);
}
}
} while (end<=lengthOfPage);
regfree (&preg);
}
quelqu'un aurait il une idée pour récupérer tout les liens necessaires proprement?
merci d'avance