C#通过程序登录https网站

时间:2012-08-03 12:21:32

标签: c# post connect

我想使用以下凭据解析和stackoverflow1

登录网站https://ssl.aukro.ua/enter_login.php

我正在使用以下代码,但它无效

HttpWebRequest http = WebRequest.Create("https://ssl.aukro.ua/enter_login.php") as HttpWebRequest;
http.KeepAlive = true;
http.Method = "POST";
http.ContentType = "application/x-www-form-urlencoded";
string postData = "user_login=" + "parsing" + "&user_password=" + "stackoverflow1";
byte[] dataBytes = UTF8Encoding.UTF8.GetBytes(postData);
http.ContentLength = dataBytes.Length;
using (Stream postStream = http.GetRequestStream())
{
    postStream.Write(dataBytes, 0, dataBytes.Length);
}
HttpWebResponse httpResponse = http.GetResponse() as HttpWebResponse;
// Probably want to inspect the http.Headers here first
http = WebRequest.Create("http://aukro.ua/myaccount/bid.php") as HttpWebRequest;
http.CookieContainer = new CookieContainer();
http.CookieContainer.Add(httpResponse.Cookies);
HttpWebResponse httpResponse2 = http.GetResponse() as HttpWebResponse;

1 个答案:

答案 0 :(得分:1)

登录时检查POST会显示其他几个参数:

cod OGZkZlVlNmJk
global_login_hash   83a8ead80c5c544c86c51ab9914db0ab891d7223
session OWFhMANRVl5dVlVUVFoDCAlTBVFQB1QNDVZQVlFTU11cUAVSVFMDDwpRVVVTVgdZCFZSA1JSYmMyOA==
session_login_hash  38d1a6b20f20d7cb7a8cf93d7f3048087d8c9ffb
url ODNiOF5HRxICHE1PQUQdA01YEFcYRlI2MzNi
user_login  test
user_password   test
version A

您需要从登录页面解析这些内容并将其添加到您的帖子中。

相关问题