Sometimes you need to obtain the cookie of the website where the webbrowser is located, it will be as follows:
1 |
String Cookie = webbrowser1.document. Cookie; |
However, the cookie content obtained is not all cookies that are actually included in the request. To obtain the website cookie sent by the request, you can useInternetgetcookieex is obtained from this win api. The following is an API method announcement.
1 |
[Dllimport ( "Wininet. dll" , Charset = charset. Auto, setlasterror = True )] |
2 |
Static Extern Bool Internetgetcookieex ( String Pchurl, String Pchcookiename, stringbuilder pchcookiedata, Ref System. uint32 pcchcookiedata, Int Dwflags, intptr lpreserved ); |
4 |
[Dllimport ( "Wininet. dll" , Charset = charset. Auto, setlasterror = True )] |
5 |
Static Extern Int Internetsetcookieex ( String Lpszurl, String Lpszcookiename, String Lpszcookiedata, Int Dwflags, intptr dwreserved ); |
Internetsetcookieex is used to set the cookie, which is not used in the example here, while internetgetcookieex can be used to obtain the cookie of the IE compiler, the following methods can be used to obtain cookies contained in a website after the website is accessed.
01 |
Private Static String Getcookies ( String URL) |
04 |
Stringbuilder cookiedata = New Stringbuilder (( Int ) Datasize ); |
05 |
If (! Internetgetcookieex (URL, Null , Cookiedata, Ref Datasize, 0x2000, intptr. Zero )) |
10 |
Cookiedata = New Stringbuilder (( Int ) Datasize ); |
11 |
If (! Internetgetcookieex (URL, Null , Cookiedata, Ref Datasize, 0x00002000, intptr. Zero )) |
14 |
Return Cookiedata. tostring (); |
Usage: the proxy for the getcookies upload method is to modify an unknown version on the website, and then modify the response to the previously announced API quota.