为什么我用罗马尼亚语翻译IMDB结果?

时间:2013-02-27 18:58:52

标签: c# httpwebrequest httpwebresponse

HttpWebRequest WebReq;
HttpWebResponse WebResp;
Stream Answer;
StreamReader _Answer;    
string ResponseOutput;

WebReq = (HttpWebRequest)WebRequest.Create(imdb.url);
WebReq.KeepAlive = false;
WebReq.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2.4) Gecko/20100611 Firefox/3.6.4";                
WebReq.Method = "GET";    
WebReq.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip, deflate");
WebReq.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
try
{
    using (WebResp = (HttpWebResponse)WebReq.GetResponse())
    {
        Answer = WebResp.GetResponseStream();
        _Answer = new StreamReader(Answer);
        ResponseOutput = _Answer.ReadToEnd();
    }
}
catch (WebException ex) {return null;}

为什么我用罗马尼亚语翻译了这个页面?如果我使用http://www.imdb.com/title/tt1606378/调用此代码,我会收到包含<title>Si mai greu de ucis (2013) - IMDb</title>而不是<title>A Good Day to Die Hard (2013) - IMDb</title>的回复吗?

1 个答案:

答案 0 :(得分:2)

这对我来说很好,但我怀疑他们正在进行地理定位,以便在没有语言标题的情况下获取您的语言。

我建议使用Accept-Language标头en作为值:

WebReq.Headers.Add("Accept-Language", "en");