终于可以读到网页源文件。
代码共享如下,注意,是源文件,不是经过IE加工过的那个html文件,是你浏览网页的时候查看源文件里那个源文件。
function GetHtml(const WebBrowser:
TWebBrowser): string; const BufSize = $10000; var Size: Int64; Stream: IStream; hHTMLText: HGLOBAL; psi: IPersistStreamInit; begin if not Assigned(WebBrowser.Document) then Exit; OleCheck(WebBrowser.Document.QueryInterface
(IPersistStreamInit, psi)); try //OleCheck(psi.GetSizeMax(Size)); hHTMLText := GlobalAlloc(GPTR, BufSize); if 0 = hHTMLText then RaiseLastWin32Error; OleCheck(CreateStreamOnHGlobal(hHTMLText,
True, Stream)); try OleCheck(psi.Save(Stream, False)); Size := StrLen(PChar(hHTMLText));
SetLength(Result, Size); CopyMemory(PChar(Result), Pointer(hHTMLText), Size); finally Stream := nil; end; finally psi := nil; end; end; 感谢delphibbs的离线数据库,在每一次的开发中,都给了我很大的帮助,感谢我的朋友心灵神鹰,他总是给我无私的帮助。 本文出自 51CTO.COM技术博客 |


wenyan
博客统计信息
热门文章
最新评论
友情链接