Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- csrfmiddlewaretoken "7e9001a3c0000f11099c11h119745e30"
- username "логин"
- password "пароль"
- next "/about/"
- WebResponse Response;
- HttpWebRequest Request;
- Uri url = new Uri("http://00.00.00.000:0000/accounts/login/");
- CookieContainer cookieContainer = new CookieContainer();
- Request = (HttpWebRequest)WebRequest.Create(url);
- Request.Method = "GET";
- Request.CookieContainer = cookieContainer;
- Response = Request.GetResponse(); //1 раз получил csrfmiddlewaretoken
- string Parametros = "csrfmiddlewaretoken=" + cookieContainer.GetCookies(url)["csrftoken"].Value + "&username=логин&password=пароль&next=/about/";
- Request = (HttpWebRequest)WebRequest.Create(url);
- //вот тут получается мне выдадут потом новый токен, а без использования этого я не знаю как сформировать новый запрос
- Request.Method = "POST";
- Request.ContentType = "application/x-www-form-urlencoded";
- Request.CookieContainer = cookieContainer;
- Request.Headers.Add("Cookie", Response.Headers.Get("Set-Cookie"));
- byte[] byteArray = Encoding.UTF8.GetBytes(Parametros);
- Request.ContentLength = byteArray.Length;
- Response = Request.GetResponse();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement