具体的には、Web サイトにログインして、ログイン ページの後に自動的にリダイレクトされるhttp://www.probux.com/login.php
コンテンツを取得しようとしています。http://www.probux.com/account.php
私は WebRequests にかなり慣れていないので、ばかげて間違ったことをしている場合は、許してください (笑)。とにかく、ここに私の現在のコードがあります:
private void button1_Click(object sender, EventArgs e)
{
string user = textBox1.Text;
string pass = textBox2.Text;
ASCIIEncoding encoding = new ASCIIEncoding();
string postData = "user=" + user + "&pass=" + pass;
byte[] data = encoding.GetBytes(postData);
WebRequest request = WebRequest.Create("https://www.probux.com/login.php");
request.Proxy = null;
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = data.Length;
Stream stream = request.GetRequestStream();
stream.Write(data, 0, data.Length);
stream.Close();
WebResponse response = request.GetResponse();
stream = response.GetResponseStream();
StreamReader reader = new StreamReader(stream);
richTextBox1.Text = reader.ReadToEnd();
reader.Close();
stream.Close();
}
現在、これを行うと、ログインページのデータを取得するだけで、その後にリダイレクトされるページは取得されません。私はこれをかなりの時間理解しようとしてきましたが、間違った場所を探しているだけかどうかはわかりませんが、私がやろうとしていることに関するドキュメントはあまりないようです.
この件に関するヘルプは大歓迎です。