簡體   English   中英

Web瀏覽器無法打開Instagram C#

[英]WebBrowser cant open Instagram c#

當我將Instagram的地址放在我的WebBrowser對象中時,在加載程序時,它僅顯示一個空白的白頁,而沒有其他問題,這是什么地方? 首先,我認為這應該是導致WebBrowser使用IE的原因,但是IE(ver.11)成功加載了Instagram

更新:這是我使用的代碼:

            this.webB.Location = new System.Drawing.Point(93, 17);
            this.webB.MinimumSize = new System.Drawing.Size(20, 20);
            this.webB.Name = "webB";
            this.webB.Size = new System.Drawing.Size(642, 324);
            this.webB.TabIndex = 1;
            this.webB.Url = new System.Uri("https://www.instagram.com/", System.UriKind.Absolute);
            this.webB.DocumentCompleted += new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(this.webB_DocumentCompleted);
            this.webB.ScriptErrorsSuppressed = true;

試試這個:)。 此代碼對於加載URL(例如Instagram)和下載相應頁面的源代碼很有用。

 protected void LoadUrl(object sender, EventArgs e) { string url = txtUrl.Text.Trim(); Thread thread = new Thread(delegate() { using (WebBrowser browser = new WebBrowser()) { browser.ScrollBarsEnabled = false; browser.AllowNavigation = true; browser.Navigate(url); browser.Width = 1024; browser.Height = 768; browser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(DocumentCompleted); while (browser.ReadyState != WebBrowserReadyState.Complete) { System.Windows.Forms.Application.DoEvents(); } } }); thread.SetApartmentState(ApartmentState.STA); thread.Start(); thread.Join(); } private void DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { WebBrowser browser = sender as WebBrowser; string sourcecode=browser.documentText; } 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM