码迷,mamicode.com
首页 > Web开发 > 详细

delphi webbrowser 获取网页源码

时间:2014-05-09 16:20:59      阅读:424      评论:0      收藏:0      [点我收藏+]

标签:style   blog   class   code   java   ext   

转自 http://hi.baidu.com/delphidiary

转自 http://blog.sina.com.cn/s/blog_725fb194010150jh.html

 

 

 

bubuko.com,布布扣
//前面要加几个pas单元
uses Registry,ShellApi, WinInet,ShlObj,ComObj;
//========================================删COOKIES========================== procedure DelRegCache; var reg:TRegistry; begin reg:=Tregistry.create; reg.RootKey:=HKEY_CURRENT_USER; reg.DeleteKey(Software\Microsoft\Internet Explorer\TypedURLs); reg.Free; end; function GetCookiesFolder:string; var pidl:pItemIDList; buffer:array [ 0..255 ] of char ; begin SHGetSpecialFolderLocation( application.Handle , CSIDL_COOKIES, pidl); SHGetPathFromIDList(pidl, buffer); result:=strpas(buffer); end; function ShellDeleteFile(sFileName: string): Boolean; var FOS: TSHFileOpStruct; begin FillChar(FOS, SizeOf(FOS), 0); {记录清零} with FOS do begin wFunc := FO_DELETE;//删除 pFrom := PChar(sFileName); fFlags := FOF_NOCONFIRMATION; end; Result := (SHFileOperation(FOS) = 0); end; //删除cookies procedure DelCookie; var dir:string; begin try InternetSetOption(nil, INTERNET_OPTION_END_BROWSER_SESSION, nil, 0); dir:=GetCookiesFolder; ShellDeleteFile(dir+\*.txt+#0); //网上很多代码这里没有加最后的#0,在xp下经测试会报错 except abort; end; end; //========================================删COOKIES=========================




bubuko.com,布布扣

 

bubuko.com,布布扣
 USES mshtml

procedure TForm1.WebBrowser1DocumentComplete(ASender: TObject; 2 const pDisp: IDispatch; var URL: OleVariant); 3 var 4 i:Integer; 5 iall : IHTMLElement; 6 begin 7 if WebBrowser1.Application = pDisp then 8 begin 9 Memo1.Clear; 10 if Assigned(WebBrowser1.Document) then 11 begin 12 iall := (WebBrowser1.Document AS IHTMLDocument2).body; 13 while iall.parentElement <> nil do 14 begin 15 iall := iall.parentElement; 16 end; 17 Memo1.Text := Memo1.Text+iall.outerHTML; 18 end; 19 end; 20 end;
bubuko.com,布布扣

 

 

delphi webbrowser 获取网页源码,布布扣,bubuko.com

delphi webbrowser 获取网页源码

标签:style   blog   class   code   java   ext   

原文地址:http://www.cnblogs.com/didiwei/p/3718149.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!