c# webbrowser控件 如何将打开的网页自动保存为本地html文件?

c# 如何将在webbrowser中打开的网页自动保存为本地html文件?

最好附带一段代码,谢谢

第1个回答  2020-03-20
我的完全可以,请黏贴如下代码看看呢?(我用maxthon最新版本的):

以下是aspx代码:
<%@
page
language="c#"
autoeventwireup="true"
codebehind="webform7.aspx.cs"
inherits="testwebdemo.webform7"
enableviewstate="false"
%>
<!doctype
html
public
"-//w3c//dtd
xhtml
1.0
transitional//en"
"
http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html
xmlns="
http://www.w3.org/1999/xhtml">
<head
runat="server">

<title>viewstate
demo</title>
</head>
<body>

<form
id="form1"
runat="server"
method=get>

<div>

<input
type=textbox
value='
<%=configurationmanager.appsettings["constr"]%>'

style='width:734px'
/>

</div>

</form>
</body>
</html>

以下是配置文件:
<configuration>

<appsettings>

<add
key="constr"
value="server=server2;database=test;uid=*****;pwd=*****"/>

</appsettings>
<connectionstrings>
<add
name="northwindconnectionstring"
connectionstring="data
source=.\sqlexpress;initial
catalog=northwind;integrated
security=true"
providername="system.data.sqlclient"/>
</connectionstrings>
....
第2个回答  2010-05-26
先读取页面内容,然后用IO写入HTML
第3个回答  2010-05-26
HttpWebRequest wReq = (HttpWebRequest)WebRequest.Create("http://www.crazycoder.cn/");
wReq.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322; .NET CLR 2.0.50215; " + Guid.NewGuid().ToString() + ")";

HttpWebResponse wResp = wReq.GetResponse() as HttpWebResponse;
wReq.AllowAutoRedirect = true;
// 获取输入流
System.IO.Stream respStream = wResp.GetResponseStream();

System.IO.StreamReader reader = new System.IO.StreamReader(respStream, encode);
string content = reader.ReadToEnd();
reader.Close();
reader.Dispose();
respStream.Close();
respStream.Dispose();
wResp.Close();本回答被提问者采纳
第4个回答  2010-05-26
这个问题好像不太好弄
相似回答