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

2024-12-16 12:07:37
推荐回答(4个)
回答1:

我的完全可以,请黏贴如下代码看看呢?(我用maxthon最新版本的):

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

viewstate<br>demo



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



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

style='width:734px'
/>







以下是配置文件:




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



name="northwindconnectionstring"
connectionstring="data
source=.\sqlexpress;initial
catalog=northwind;integrated
security=true"
providername="system.data.sqlclient"/>

....

回答2:

先读取页面内容,然后用IO写入HTML

回答3:

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:

这个问题好像不太好弄