該頁面最初顯示價格和專案,但在獲得結果時只看到標題。
private void Form1_Load(object sender, EventArgs e)
{
string q = "https://www.g2g.com/categories/counter-strike-global-offensive-item";
using (WebClient client = new WebClient())
{
client.Headers.Add("user-agent", "foo");
client.UseDefaultCredentials = true;
client.Headers[HttpRequestHeader.UserAgent] = "Mozilla / 5.0(Windows NT 10.0; Win64; x64; rv: 44.0) Gecko / 20100101 Firefox / 44.0";
client.Encoding = Encoding.UTF8;
string htmlcode = client.DownloadString(q);
asss.Text = htmlcode;
}
}
}
怎么樣
照片
我得到了什么
照片
uj5u.com熱心網友回復:
似乎您忘記使用呈現 HTML 并執行 JavaScript 的控制元件(如WebBrowser或較新的WebView2)而不是普通的 TextBox 或 LinkLabel (如純文本內容所示)。
您可以通過WebBrowser.DocumentText設定使用 WebClient 檢索到的頁面內容。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/389776.html
上一篇:C#使其他按鈕列單元格在單擊其中一個單元格時不可單擊
下一篇:在不單擊行的情況下獲取DataGridView列中的最高數字,以在另一個表單上生成ID欄位。(C#Windows表單應用程式)
