在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
1 this.webBrowser.Navigate(webBrowserUrl, tagerFrameName, postBuffer, heads); 2 this.webBrowser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(WebBrowser_DocumentCompleted); 3 4 void WebBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) 5 { 6 WebBrowser webBrowser = (WebBrowser)sender; 7 //WebBrowserReadyState.Interactive 和WebBrowserReadyState.Complete 时都会触发DocumentCompleted 8 if (webBrowser.ReadyState == WebBrowserReadyState.Complete) 9 { 10 //webBrowser1.DocumentText 获取的内容中文会乱码 11 //获取文档编码 12 Encoding encoding = Encoding.GetEncoding(webBrowser.Document.Encoding); 13 StreamReader stream = new StreamReader(webBrowser.DocumentStream, encoding); 14 File.WriteAllText(@"D:\mzwu.txt", stream.ReadToEnd(), Encoding.Unicode); 15 MessageBox.Show(DateTime.Now.ToString() + ": 页面内容获取完成! "); 16 } 17 }
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论