我正在尝试管理此站点上的重定向:https://uk.soccerway.com,所以我编写了以下代码:
public static string GetHtml(string url)
{
HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(url);
try
{
webReq.AllowAutoRedirect = false;
HttpWebResponse response = webReq.GetResponse() as HttpWebResponse;
WebClient client = new WebClient();
client.Encoding = System.Text.Encoding.UTF8;
url = (response.Headers["Location"] != null) ? response.Headers["Location"] : url;
return client.DownloadString(url);
}
catch (WebException)
{
throw;
}
}
这将返回一个异常,特别是:
“远程服务器返回错误:(302)临时移动。”
我做错了什么?
相关分类