网上方法一:(可获取,但不完全)
引用mshtml;
IHTMLDocument(wb1.Document).cooke;
网上方法二:(获取不到!)
引用winnet,使用InternetGetCookieEx
function GetCookie(url: string): string; const INTERNET_COOKIE_HTTPONLY = $00002000; INTERNET_COOKIE_THIRD_PARTY = $00000010; INTERNET_FLAG_RESTRICTED_ZONE= $00020000; var hModule:THandle; InternetGetCookieEx:function(lpszUrl, lpszCookieName,lpszCookieData: PChar; var lpdwSize: DWORD;dwFlags:DWORD;lpReserved: Pointer): BOOL;StdCall; CookieSize:DWORD; cookiedata:PWideChar; thebool:bool; begin result := ''; hModule:=GetModuleHandle('wininet.dll'); if hModule<>0 then begin @InternetGetCookieEx:=GetProcAddress(hModule,'InternetGetCookieExW'); if @InternetGetCookieEx<>nil then begin CookieSize:=10240; Cookiedata := AllocMem(CookieSize); thebool:=InternetGetCookieEx(PWideChar(url),nil,CookieData,CookieSize,INTERNET_COOKIE_HTTPONLY,nil); if thebool then result := CookieData; FreeMem(Cookiedata); end; FreeLibrary(hModule); end; end;
方法三:
引用winnet,直接调用InternetGetCookie
function GetWBCookies(URL: string): string;
var data : array[0..10240] of Byte; datalen : cardinal; begin Result := ''; datalen := sizeof(data); if InternetGetCookie(PChar(URL), nil, @data,datalen) then Result := PChar(@data); end;