bonjour,


cette partie est apparemment reservé au Php mais je ne sais pas trop ou le mettre :s

je chercher a relever les liens dans une page html

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
 
"href *= *\"?([^\" >]*)"
Sauf que je ne voudrais n'avoir en sorti que l'adresse sans le "href"

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
void regCompile(regex_t *reg, int *nmatch, const char *maRegexp){
 
	if (regcomp (reg, maRegexp, REG_EXTENDED) != 0){
		exit(-1);
	}
 
	*nmatch = reg->re_nsub;
}
 
void extractLinks(Page *page){
	regex_t reg;
	const char *maRegexp = "href *= *\"?([^\" >]*)";
	int nmatch;
	int size;
 
	regCompile (&reg, &nmatch, maRegexp);
 
	regmatch_t *pmatch = (regmatch_t *)malloc (sizeof(regmatch_t *) *nmatch);
	if (pmatch == NULL){
		fprintf(stderr, "Probleme d'allocation memeoire\n");
	}	
 
	while(regexec (&reg, page->page, nmatch, pmatch, 0) == 0){
		size = pmatch[0].rm_eo - pmatch[0].rm_so;
		appendToList(page->listURL, strndup(&(page->page[pmatch[0].rm_so]) ,size)); /* ce que je récupère */
		page->page+=pmatch[0].rm_eo;
	BUG
	}
 
}
en sortie j'ai

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
 
href="http://www.esiee.fr/~givernao/curl/2.html
href="http://www.esiee.fr/~givernao/curl/3.html
href="http://www.esiee.fr/~givernao/curl/4.html
href="http://www.esiee.fr/~givernao/curl/5.html
Cordialement

trax