编码在kinoposik的俄国文本

时间:2016-03-27 12:40:20

标签: c# request httpwebrequest httprequest

我想在kinopoisk上解析一个电影页面,但在回复俄语文本看起来像“ЕсливампонравилсяэС,РѕС”。我尝试了不同的编码,但无法解决问题。

        int y = 2008;
        string n = "Hancock";

        HttpWebRequest req = (HttpWebRequest)
            WebRequest.Create($@"http://www.kinopoisk.ru/s/type/film/find/{n}/m_act%5Byear%5D/{y}/");

        req.Method = "GET";
        req.UserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36";
        req.Accept = @"text/html,application/xhtml+xml,application/xml;q=0.9,";
        req.KeepAlive = true;

        using (StreamReader reader = new StreamReader(req.GetResponse().GetResponseStream(), Encoding.GetEncoding("windows-1251")))
        {
            File.WriteAllText(@"C:\test\MyTest.html", reader.ReadToEnd());
        }

0 个答案:

没有答案