[英]Get webpage source code with alt key code symbols using asp.net c#
我正在嘗試使用htmlagilitypack獲取網頁源代碼。 這是我的代碼,用於獲取源代碼並填充到多行文本框中:
var url = "http://www.example.com";
var web = new HtmlWeb();
var doc = web.Load(url);
sourcecodetxt.Text = doc.ToString();
代碼可以正常工作,但是如果我的網頁上有一些“ Alt Codes Symbols”,則符號會更改為某些字符,例如: ★
更改為★
我的問題是如何獲取原始符號。 對不起,我的英語不好。 提前致謝。
嘗試使用WebClient
和HtmlDocument
的Load()
方法,以便您可以指定編碼:
WebClient client = new WebClient();
HtmlDocument doc = new HtmlDocument();
doc.Load(client.OpenRead("http://www.example.com"), Encoding.UTF8);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.