0

我正在尝试抓取此 URL

http://www.fbr.gov.pk/SROsAmending.aspx?Department=销售税

下面是我的代码,但它不起作用。如何抓取其分页网格视图的第二页或第三页?

 <code>
 WebRequest request = 
 WebRequest.Create("http://www.fbr.gov.pk/SROsAmending.aspx?Department=Sales Tax");

 request.Method = "POST";

 string postData = "__EVENTTARGET=ctl00$ContentPlaceHolder1$grdArticals";

 postData = postData + "&__EVENTARGUMENT=Page$3";

 byte[] byteArray = Encoding.UTF8.GetBytes(postData);

 request.ContentType = "application/x-www-form-urlencoded";

 request.ContentLength = byteArray.Length;

 Stream dataStream = request.GetRequestStream();

 dataStream.Write(byteArray, 0, byteArray.Length);

 dataStream.Close();

 WebResponse response = request.GetResponse();

 string test = ((HttpWebResponse)response).StatusDescription;

 dataStream = response.GetResponseStream();

 StreamReader reader = new StreamReader(dataStream);

 string responseFromServer = reader.ReadToEnd();

 reader.Close();
 dataStream.Close();
 response.Close();

</code>
4

0 回答 0