public DocumentInfo Brower(string url) { var document = new DocumentInfo() { Url = url }; if (string.IsNullOrEmpty(url)) { return document; } if (this.HttpRequestUrls.Count > 0) { this.HttpRequestUrls.Clear(); } this.WB.Navigate(url); var flage = false; var sw = new Stopwatch(); sw.Start(); while (!this.IsDocumentFinish) { Application.DoEvents(); Thread.Sleep(50); sw.Stop(); if (sw.ElapsedMilliseconds >= this.TimeOut * 1000) { flage = true; break; } sw.Start(); } sw.Stop(); if (flage) { return document; } this.Elapse = sw.Elapsed.Milliseconds; this.IsDocumentFinish = false; document.HtmlSource = this.WB.DocumentSource; document.HttpRequestUrls = this.HttpRequestUrls; document.Title = this.WB.DocumentTitle; document.Elapse = this.Elapse; if (this.GetCharset) { var doc = this.WB.WebbrowserObject.Document as IHTMLDocument2; if (doc != null) { document.Encoding = doc.charset; } } // 获取ie浏览器版本 if (string.IsNullOrEmpty(this.IEVersion)) { this.IEVersion = this.WB.IEVersion(); } return document; }
private DocumentInfo GetDocumentInfo() { var documenrInfo = new DocumentInfo(); var doc2 = (IHTMLDocument2)WB.WebbrowserObject.Document; if(doc2!=null) { documenrInfo.Url = doc2.url; documenrInfo.Domain = doc2.domain; documenrInfo.Protocol = doc2.protocol; documenrInfo.Cookie = doc2.cookie; documenrInfo.Referrer = doc2.referrer; } return documenrInfo; }
public DocumentInfo Brower(string url) { var document = new DocumentInfo() { Url = url }; if (string.IsNullOrEmpty(url)) { return(document); } if (this.HttpRequestUrls.Count > 0) { this.HttpRequestUrls.Clear(); } this.WB.Navigate(url); var flage = false; var sw = new Stopwatch(); sw.Start(); while (!this.IsDocumentFinish) { Application.DoEvents(); Thread.Sleep(50); sw.Stop(); if (sw.ElapsedMilliseconds >= this.TimeOut * 1000) { flage = true; break; } sw.Start(); } sw.Stop(); if (flage) { return(document); } this.Elapse = sw.Elapsed.Milliseconds; this.IsDocumentFinish = false; document.HtmlSource = this.WB.DocumentSource; document.HttpRequestUrls = this.HttpRequestUrls; document.Title = this.WB.DocumentTitle; document.Elapse = this.Elapse; if (this.GetCharset) { var doc = this.WB.WebbrowserObject.Document as IHTMLDocument2; if (doc != null) { document.Encoding = doc.charset; } } // 获取ie浏览器版本 if (string.IsNullOrEmpty(this.IEVersion)) { this.IEVersion = this.WB.IEVersion(); } return(document); }