WebClient -如何在你POST'

本文关键字:POST WebClient | 更新日期: 2023-09-27 18:10:52

我使用的是修改过的CookieAwareWebClient类。

我希望它如何工作:我使用post登录,然后去搜索页面,我张贴类别的id,作为回报,我希望它给我列出类别的网站来源。我已经设法在Python上做到了这一点,它工作得很好,但在c#上,我认为我在这里做错了什么。

ServicePointManager.Expect100Continue = false;
var client = new CookieAwareWebClient();
client.BaseAddress = @"http://site/";
// Logging in...
// This part works fine
var loginData = new NameValueCollection();
loginData.Add("login", "user");
loginData.Add("pass", "pass");
client.UploadValues("http://site/authorize.html", "POST", loginData);
// Searching for items
// Not so sure about this part since cannot read what is given back
var searchData = new NameValueCollection();
searchData.Add("catName", "tables");
client.UploadValues("http://site/search.html", "POST", searchData);

WebClient -如何在你POST'

WebClient.UploadValues以字节数组的形式返回响应,但您目前忽略了它。这就是你想要的数据吗?