Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. static void Main(string[] args)
  2. {
  3. Console.WriteLine("f");``
  4.  
  5. Console.ReadLine();
  6. string LoginSite(string url, string username, string password)
  7.  
  8. HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
  9. string cookie = "";
  10.  
  11. //this values will change depending on the website
  12. string values = "vb_login_username=" + username + "&vb_login_password="
  13. + password
  14. + "&securitytoken=guest&"
  15. + "cookieuser=checked&"
  16. + "do=login";
  17.  
  18. req.Method = "POST";
  19. req.ContentType = "application/x-www-form-urlencoded";
  20. req.ContentLength = values.Length;
  21. CookieContainer a = new CookieContainer();
  22. req.CookieContainer = a;
  23. System.Net.ServicePointManager.Expect100Continue = false; // prevents 417 error
  24. using (StreamWriter writer = new StreamWriter(req.GetRequestStream(),
  25. System.Text.Encoding.ASCII)) { writer.Write(values); }
  26. HttpWebResponse c = (HttpWebResponse)req.GetResponse();
  27. Stream ResponseStream = c.GetResponseStream();
  28. StreamReader LeerResult = new StreamReader(ResponseStream);
  29. string Source = LeerResult.ReadToEnd();
  30.  
  31.  
  32. foreach (Cookie cook in c.Cookies) { cookie = cookie + cook.ToString() + ";"; }
  33. return cookie
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement