我正在尝试登录该网站并从标题中获取 Cookie,但它不起作用。所以这是我的代码
如果登录成功,则 fshare_userid 的值必须为 2312158
CookieContainer cookie = new CookieContainer();
// Set Cookie
string url = "https://www.fshare.vn/login.php";
string parameters = "login_useremail=nguoivodanhbtallshare@yopmail.com&login_password=123456&url_refe=http://www.fshare.vn/";
// create a request
HttpWebRequest request = (HttpWebRequest)
WebRequest.Create(url); request.KeepAlive = false;
request.ProtocolVersion = HttpVersion.Version10;
request.Method = "POST";
byte[] postBytes = Encoding.ASCII.GetBytes(parameters);
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = postBytes.Length;
request.CookieContainer = cookie;
Stream requestStream = request.GetRequestStream();
requestStream.Write(postBytes, 0, postBytes.Length);
requestStream.Close();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
string responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
foreach (Cookie c in cookie.GetCookies(response.ResponseUri))
{
richTextBox1.Text += "Name : " + c.Name + "\n";
richTextBox1.Text += "Value : " + c.Value + "\n\n";
}
webBrowser1.DocumentText = responseString;