0

所以我试图通过首先单击下拉列表中的项目来导航http://www.historicflyingclothing.com/shop.php 。使用以下命令从下拉列表中发布值后:

string poststring = String.Format("Cat1={0}", "7");
CookieContainer cookie = new CookieContainer();
HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create("http://www.historicflyingclothing.com/shop.php");

httpRequest.Method = WebRequestMethods.Http.Post;
httpRequest.CookieContainer = cookie;
httpRequest.AllowWriteStreamBuffering = true;
httpRequest.ProtocolVersion = HttpVersion.Version11;
httpRequest.AllowAutoRedirect = true;
httpRequest.ContentType = "application/x-www-form-urlencoded";

byte[] bytedata = Encoding.UTF8.GetBytes(poststring);
httpRequest.ContentLength = bytedata.Length;

Stream requestStream = httpRequest.GetRequestStream();
requestStream.Write(bytedata, 0, bytedata.Length);
requestStream.Close();


HttpWebResponse httpWebResponse = (HttpWebResponse)httpRequest.GetResponse();
Stream responseStream = httpWebResponse.GetResponseStream();

我能够获取页面上的项目。问题是当我需要单击下一步按钮时。我希望使用CookieContainer来帮助我导航,但我无法弄清楚帖子数据应该是什么。下次点击的html代码为:

<form method="POST" class="shopform" action="shop.php"> 
    <p style="text-align: center"> <input type="IMAGE" name="Submitnext" src="buttons/next.gif" value="npage" style="margin-bottom: -4pt"></p>
</form>

下拉列表中的名称为“Cat1”,值为“7”,但我要为这个图像使用什么?

4

1 回答 1

0

从您提供并在该网站上列出的 HTML 中,您需要发布的值是:

提交next=npage

您会注意到您发布的名称包含在“名称”属性中,而值包含在“值”属性中。

于 2013-02-27T06:32:11.707 回答