Slt,

j'ai un soucis avec un code que l'on m'a filé ici

j'utilise ce code pour lire une page web qui change de quelques caracteres entre 2 appels, le probleme est que chaque fois que je lis ma page, j'obtiens le meme resultat (soit le 1er obtenu alors, qu'il change, verif faite en direct avec firefox)

j'ai l'impression que la page est stoquée en cache kk part, et du coup, c'est le cache que j'obtiens chaque fois.

mon code :

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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
 
CString GetWebPage(int numPage, CString login, CString password, CString id, CString param )
{
	#define TAILLE_BUFFER 256
	CString url = "http://url.de.ma.page.com?p=", sRead = "";	
	HINTERNET hInternetSession, hHttpSession;
	char buffer[TAILLE_BUFFER];
	DWORD dwRead;
 
	DWORD dwSize = 20;
	LPVOID lpOutBuffer = new char[dwSize];
 
	switch (numPage){
		case 1 : url += "51"; break;
		case 2 : url += "53"; break;
		case 3 : url += "55"; break;
		case 4 : url += "57"; break;
	}
	if (id != "") url += "&id=" + id;
 
	if (param != "") url += param;
 
	url += "&login=" + login + "&password=" + password;
 
	hInternetSession = InternetOpen ("MaPage", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, NULL) ;
	if (hInternetSession)
   {
	   hHttpSession  = InternetOpenUrl( hInternetSession, url, NULL, 0, 0, 0 ) ;
	   if (!hHttpSession)
	   {
		   InternetCloseHandle (hInternetSession) ;
		   sRead = "<ERREUR>";
		}
	   else
	   {
		   //*************************************************************************************//
		   // Lecture du HEADER HTTP (en cas d'erreur de mot de passe : Content-Type: text/bad_pw 
		   //*************************************************************************************//
			sprintf((char *)lpOutBuffer,"Content-Type");
			if(!HttpQueryInfo(hHttpSession,HTTP_QUERY_CUSTOM, (LPVOID)lpOutBuffer,&dwSize,NULL))
			{
				if (GetLastError()==ERROR_HTTP_HEADER_NOT_FOUND)
				{
					// Code to handle the case where the header isn't available.
					sprintf((char *)lpOutBuffer,"");
				}		
				else
				{
					// Check for an insufficient buffer.
					if (GetLastError()==ERROR_INSUFFICIENT_BUFFER)
					{
						// Allocate the necessary buffer.
						lpOutBuffer = new char[dwSize];
 
						// Rewrite the header name in the buffer.
						//StringCchPrintfA( (LPSTR)lpOutBuffer, dwSize,"Content-Type" );
						sprintf((char *)lpOutBuffer,"Content-Type");
 
						// Retry the call.
						// goto retry;				
					}		
					else
					{
						// Error handling code.
						sprintf((char *)lpOutBuffer,"");
					}		
				}		
			}
			if (strcmp("Content-Type", (char *)lpOutBuffer)!=0) // erreur
			{
				if (strcmp("text/bad_pw", (char *)lpOutBuffer)==0)
				{
					sRead = "<BAD>";
				}
				else if (strcmp("text/ko", (char *)lpOutBuffer)==0)
				{
					sRead = "<ERROR>";
				}
				else if (strcmp("text/ok", (char *)lpOutBuffer)==0)
				{
					sRead = "<OK>";
				}
				else
				{
					sRead = "<ERROR_CONNECTION>";
				}
 
			}
			//*************************************************************************************//
 
			if (sRead=="")
			{
				while ( InternetReadFile( hHttpSession, buffer, TAILLE_BUFFER-1, &dwRead ) )
				{
					if ( dwRead == 0 )
						break;
					buffer[dwRead] = 0;
					sRead += buffer;
				}
			}
 
			InternetCloseHandle( hHttpSession );
			InternetCloseHandle (hInternetSession) ;
	   }
   }
   return sRead;
}