开发者

WebClient - How to get source after you POST'ed something

开发者 https://www.devze.com 2023-04-12 00:55 出处:网络
I\'m using WebClient with modified CookieAwareWebClient class. How I want it to work: I log in using post, then go to search page where I post id of c开发者_JAVA技巧ategory and in return I want it to

I'm using WebClient with modified CookieAwareWebClient class.

How I want it to work: I log in using post, then go to search page where I post id of c开发者_JAVA技巧ategory and in return I want it to give me source of website that lists categories. I've managed to do that on Python and it is working fine, but on C# I think I'm doing something wrong here.

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.UploadValues returns the response as a byte array, but you're currently ignoring that. Is that actually the data you want?

0

精彩评论

暂无评论...
验证码 换一张
取 消