HttpWebRequest请求数据报错
本帖最后由 swiminwater 于 2013-02-05 14:46:41 编辑
报错内容:远程服务器返回错误: (403) 已禁止。
我使用类HttpWebRequest抓取http://www.sse.com.cn/disclosure/announcement/regular/ 地址下的预约披露情况数据。报以上错误。
前几天还能抓取,我使用httpwatch 跟踪的数据地址为:http://query.sse.com.cn/infodisplay/queryBltnBookInfo.do?jsonCallBack=jsonpCallback2227&isPagination=true&bulletintype=L011&publishYear=2012&cmpCode=&startTime=&pageHelp.pageNo=3&pageHelp.beginPage=1&pageHelp.endPage=5&sortName=companyCode&direction=asc&_=1360045417487
代码为:
if (true)
{
try
{
HttpWebRequest request = WebRequest.Create(strUrl) as HttpWebRequest;
request.Timeout = 90000;
request.KeepAlive = false;
request.Method = "GET";
request.UserAgent = "Mozilla/Ie";
request.ContentType = "application/x-www-form-urlencoded";
// 接收返回的页面
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
System.IO.Stream responseStream = response.GetResponseStream();
//Encoding.UTF8 || Encoding.Default 编码格式
System.IO.StreamReader reader = new System.IO.StreamReader(responseStream, System.Text.Encoding.UTF8);
strHtml = reader.ReadToEnd();
}
catch (Exception ex)
{
throw ex;
}
请大侠帮忙,看看怎么修改代码才能抓取数据出来。在线等....如果有分,我一定分给大家,希望大侠帮忙!!!
C#,
HttpWebRequest
抓取