【发布时间】:2021-01-16 11:17:37
【问题描述】:
尝试解析站点:link
下载内容的代码:
WebClient client = new WebClient();
client.Encoding = System.Text.Encoding.ASCII; // OR UTF8
string reply = client.DownloadString(url);
回复:
<!DOCTYPE HTML>
<html prefix="og: http://ogp.me/ns#">
<head><meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<link rel="icon" type="image/vnd.microsoft.icon" href="https://spravnik.com/favicon.ico"/>
<link rel="SHORTCUT ICON" href="https://spravnik.com/favicon.ico"/>
<link href="/src/main.css?v=1.25" rel="stylesheet" type="text/css" />
<script src="https://cdn.contentsitesrv.com/js/push/subscribe.js?v=1.3.0"></script>
<title>??????????? 12 ??????? ??. - ?????????? ?????????? ??????</title>
<meta name="keywords" content="?????????? ?????????? ????????????, ???? 09 ????????????, ?????????? ????? ????????????"/>
<meta name="description" content="? ??????????? ☎ ????????? ?? ??????? ????? ??? ???? ???????????? ?? 12 ??????? ??. ????? ???????? ?? ?????? ????????, ?????? ???????? ????? ???????? ? ????? ?? ?????? ????????."/>
<meta property="og:title" content="?????????? ??????????. ??????????? ? ?? ??????...!"/>
所有西里尔字符都转换为“???”或者在����
【问题讨论】:
-
如果使用 UTF-8 会发生什么?那么 Windows-1251 呢,因为这似乎是服务器更喜欢的?
-
使用 UTF-8(不是 ascii 会损坏数据)。您使用的查看器是 ascii,不会正确显示字符,但文件下载正确。您需要使用使用 cryillic 字符字体的查看器查看数据。
-
ASCII - ???符号 UTF-8 - ���符号 Windows-1251 未在提示列表中提供:ibb.co/Lkhz0w1
-
@jdweng ibb.co/6Rfs1HX
标签: c# webclient encode windows-1251