将Webbrowser控件的内容保存到存档页面 [英] Save content of webbrowser control to archive page

查看:125
本文介绍了将Webbrowser控件的内容保存到存档页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想构建一个程序,该程序可以捕获网站内容以存档页面(mht文件).
由于网站需要登录并访问某些页面才能获取一些会话变量.我决定使用webbrowser控件(因此,在开始捕获内容之前,我可以手动访问该页面).

我认为更改网址很容易,例如
webBrowser.Navigate("http://www.google.com")

但是下面的代码只允许我将其保存为HTML格式

I want to build a program that can capture the contents of a web site to archive page (mht file).
Since the web site need to login and access certain page to get some session variables. I decided to use the webbrowser control (and so I can access the page manually before I start capture the contents).

I think it''s easy to change the URL e.g.
webBrowser.Navigate("http://www.google.com")

But below code only allow me to save it to HTML format

Dim MSDNpage As String = webBrowser.DocumentText
My.Computer.FileSystem.WriteAllText("C:\test1.mht";, MSDNpage, True)


有什么办法将其保存为mht吗? (vb .net)
预先感谢.


Any way to save it to mht? (vb .net)
Thanks in advance.

推荐答案

您好,

看一下这篇文章,我认为它展示了您想要实现的目标.

Hello,

Have a look at this article, I think it demonstrate what you want to achieve.

Convert any URL to a MHTML archive using native .NET code[^]

Valery.


我试图按照提供的URL中的信息进行操作.但是,我发现下载的mht文件不起作用.使用IE打开它时,它无法显示原始网页. (与用IE保存的mht文件相比,它是不同的.)
我发现应该更容易,就像我叫
.ShowSaveAsDialog()

但是,打开对话框后,我不知道如何控制它.请咨询.非常感谢
I tried to follow the info in the provided URL. However, I found that the downloaded mht file is not working. When open it with IE, it can''t show the original web page. (and it''s different when compare to the mht file saved with IE).
I found that it should be easier as if I called the
.ShowSaveAsDialog()

However, I don''t know how to control the save dialog after it opened. Pls advice. Thx a lot


这篇关于将Webbrowser控件的内容保存到存档页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆