保存webBrowser中的所有内容,

newyu 2004-05-12 09:08:56
我想保存webBrowser中的所有内容包括了所有他图片,flash,javascrip,等等,并且那能用webBrowser打开.请问应该怎么实现,另外如果网页时xml写的,怎么处理.像那个网文快捕那个就做的非常好,谢谢大家
...全文
164 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
wellyn 2004-06-13
  • 打赏
  • 举报
回复
命令操作   常用的命令操作用ExecWB方法即可完成,ExecWB同样多次被重载:
     procedure ExecWB(cmdID: OLECMDID; cmdexecopt:
   OLECMDEXECOPT); overload;
     procedure ExecWB(cmdID: OLECMDID; cmdexecopt: OLECMDEXECOPT;
   var pvaIn:
       OleVariant); overload;
     procedure ExecWB(cmdID: rOLECMDID; cmdexecopt:
   OLECMDEXECOPT; var pvaIn:
       OleVariant; var pvaOut: OleVariant); overload;
     
     另存为:调用“另存为”对话框。
         ExecWB(OLECMDID_SAVEAS,OLECMDEXECOPT_DODEFAULT,
   EmptyParam,
              EmptyParam);
newyu 2004-05-13
  • 打赏
  • 举报
回复
TO:ailibuli(愛理不理)
这个仍然不能保存网页中的图片.和flash
ailibuli 2004-05-12
  • 打赏
  • 举报
回复
procedure TForm1.Button1Click(Sender: TObject);
var TempHtmlFile: String;
begin
Edit1.Text := 'http://www.yahoo.com';
TempHtmlFile := ExtractFilePath (Application.ExeName) + 'temp.html';

//用TIdHTTP控件下載一个Html放入Client
Memo1.Lines.Text := IdHTTP1.Get( Edit1.Text );
//用TMemo控件装Source
Memo1.Lines.SaveToFile( TempHtmlFile );
//用TWebBrowser控件顕示
WebBrowser1.Navigate( TempHtmlFile );
end;
newyu 2004-05-12
  • 打赏
  • 举报
回复
其实以上都不能完全保存网页的内容,例如网页中的图片,如果这个网页的中图片来自其他网站就保存不了,另外对于xml的网页也保存不了
xzhifei 2004-05-12
  • 打赏
  • 举报
回复
我也来骗分:
procedure SaveHTMLSourceToFile(const FileName: string;
WB: TWebBrowser);
var
PersistStream: IPersistStreamInit;
FileStream: TFileStream;
Stream: IStream;
SaveResult: HRESULT;
begin
PersistStream := WB.Document as IPersistStreamInit;
FileStream := TFileStream.Create(FileName, fmCreate);
try
Stream := TStreamAdapter.Create(FileStream, soReference) as IStream;
SaveResult := PersistStream.Save(Stream, True);
if FAILED(SaveResult) then
MessageBox(Handle, 'Fail to save HTML source', 'Error', 0);
finally
{ we are passing soReference in TStreamAdapter constructor,
it is our responsibility to destroy the TFileStream object. }
FileStream.Free;
end;
end;

aiirii 2004-05-12
  • 打赏
  • 举报
回复
from http://members.shaw.ca/iedelphi/webbrowser.htm

Q: How can I get the full HTML source?

A: With IE5, you can get the source by using the HTML tags outerHTML property. With IE4 or IE3, you have to save the document to a file and then load the file into a TMemo, TStrings, etc.

var
HTMLDocument: IHTMLDocument2;
PersistFile: IPersistFile;
begin
...
HTMLDocument := WebBrowser1.Document as IHTMLDocument2;
PersistFile := HTMLDocument as IPersistFile;
PersistFile.Save(StringToOleStr('test.htm'), True);

while HTMLDocument.readyState <> 'complete' do
Application.ProcessMessages;
...
end;
aiirii 2004-05-12
  • 打赏
  • 举报
回复
from http://members.shaw.ca/iedelphi/webbrowser.htm

Q: How can I get the full HTML source?

A: With IE5, you can get the source by using the HTML tags outerHTML property. With IE4 or IE3, you have to save the document to a file and then load the file into a TMemo, TStrings, etc.

var
HTMLDocument: IHTMLDocument2;
PersistFile: IPersistFile;
begin
...
HTMLDocument := WebBrowser1.Document as IHTMLDocument2;
PersistFile := HTMLDocument as IPersistFile;
PersistFile.Save(StringToOleStr('test.htm'), True);

while HTMLDocument.readyState <> 'complete' do
Application.ProcessMessages;
...
end;
hezhiwenyy2008 2004-05-12
  • 打赏
  • 举报
回复
webbrowser.saveall

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧