我花了一些时间研究这个问题,但仍然无法弄清楚。它看起来很简单,所以我觉得自己像个白痴问这个问题,但经过一段时间的研究后,我似乎无法掌握它的窍门。
我需要以编程方式登录该网站:https://wholesale.frontiercoop.com/,存储登录时的 cookie,并在下次登录时重新提交。它看起来像是一个 POST 提交(这是我在 Firefox 上使用 Firebug 收集的),所以我想出了如何存储我认为的 cookie。我只是不知道如何在下次调用该网站时提交它,因此它不会自动将我重定向到登录页面。这只是 Webbrowser 对象调用的一个参数吗?
感谢您的帮助。
对于 .NET,您必须使用 CookieContainer,例如:
HttpWebRequest req = (HttpWebRequest) WebRequest.Create ("https://wholesale.frontiercoop.com/");
req.Method = "POST";
CookieContainer container = new CookieContainer ();
req.CookieContainer = container;
// Write the POST data and get the request...
...
// ...and once the request is done, the cookie is in 'container'.
// Then, for subsequent requests you set the CookieContainer of the request to the one above
otherRequest.CookieContainer = container;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)