HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(uri);
 

//这个一定要加上,在某些网站没有会发生"远程服务器返回错误: (403) 已禁止。"错误
//myReq.UserAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; QQWubi 133; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; CIBA; InfoPath.2)";
//myReq.Method = "GET";

myReq.Method = "GET";
myReq.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
myReq.Headers.Add("Accept-Language", "zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3");
myReq.UserAgent = "Mozilla/5.0 (Windows NT 5.2; rv:12.0) Gecko/20100101 Firefox/12.0";

HttpWebResponse result = (HttpWebResponse)myReq.GetResponse();

相关文章:

  • 2021-12-02
  • 2022-12-23
  • 2022-03-13
  • 2021-07-23
  • 2022-12-23
  • 2022-01-23
  • 2021-05-21
猜你喜欢
  • 2021-08-15
  • 2022-12-23
  • 2021-08-19
  • 2022-01-14
  • 2022-12-23
  • 2022-12-23
  • 2021-04-24
相关资源
相似解决方案