所以我尝试通过首先单击下拉列表中的项目来导航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”,但是我该使用该图像做什么?
根据您提供并在该网站上列出的 HTML,您需要发布的值是:
提交下一个=npage
您会注意到您发布的名称包含在“名称”属性中,值包含在“值”属性中。