如何使用C#webbrowser中的css和js文件保存网页?
我试图将渲染的C#web浏览器保存到我的硬盘上。但它只保存html源代码,没有css或jquery js文件。我尝试了三种方法如何使用C#webbrowser中的css和js文件保存网页?,c#,jquery,web-crawler,C#,Jquery,Web Crawler,我试图将渲染的C#web浏览器保存到我的硬盘上。但它只保存html源代码,没有css或jquery js文件。我尝试了三种方法 它只创建没有任何css的html文件和jquery js文件。 File.writealText(myDocumentPath,webBrowser5.Document.Body.Parent.OuterHtml,Encoding.GetEncoding(webBrowser5.Document.Encoding)) 2.它只创建内容文本。没有html、css和js F
我在codeproject上找到了解决方案。MHTML是一条路要走。 另一种解决方案是另存为图像:
欢迎使用堆栈溢出!请带上,四处看看,并通读,尤其是
private void button1_Click(object sender, EventArgs e)
{
String source = ("viewsource.html");
StreamWriter writer = File.CreateText(source);
String myDocumentPath = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\111.html";
//It only creates only html file without any css, and jquery js files.
File.WriteAllText(myDocumentPath, webBrowser5.Document.Body.Parent.OuterHtml, Encoding.GetEncoding(webBrowser5.Document.Encoding));
//it only creates content text
File.WriteAllText(@"text.txt", webBrowser5.Document.Body.InnerText);
//It creates bigger html file, still no css or jquery js files
writer.Write(webBrowser5.DocumentText);
writer.Close();
}