[Webbrowser] [cookie] Incomplete cookies obtained by document. Cookie

Source: Internet
Author: User

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 );
3   
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)
02 {
03 Uint Datasize = 256;
04 Stringbuilder cookiedata =New Stringbuilder ((Int) Datasize );
05 If (! Internetgetcookieex (URL,Null, Cookiedata,Ref Datasize, 0x2000, intptr. Zero ))
06 {
07 If (Datasize <0)
08 Return Null;
09  
10 Cookiedata =New Stringbuilder ((Int) Datasize );
11 If (! Internetgetcookieex (URL,Null, Cookiedata,Ref Datasize, 0x00002000, intptr. Zero ))
12 Return Null;
13 }
14 Return Cookiedata. tostring ();
15 }

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.