Guest User

Untitled

a guest
Jul 10th, 2017
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Net;
  5. using System.Net.Http;
  6. using HtmlAgilityPack;
  7. using System.Text;
  8.  
  9. namespace Test
  10. {
  11. class Program
  12. {
  13. static void Main(string[] args)
  14. {
  15. // probably parsing individual post login url...
  16. // login and generating cookie session
  17. string loginURL = "https://sas.bpsecure.com/Sas/Authentication/Bigpoint?authUser=22&token=Mv-5JN9U98RwwW_lmo2f9wFwPK-j2IgcwYafVTNOlSpUgZE8uWmiIKefCvKtskeWVAx3bYrK-mRFVHELOnmk3ENN08I0Fh6QEiKKJIB55yJqaKt15kpAzp9gnXVrDmJ37Bnh2d4aVJpTAgtZr6kRFAcMZ0e6dKF9_vA5rpckhimzxKMU2gTeYJjxrrS2rt8wfQtSEmePYx3aM3R_WDncFn1ZTxti5gf3ph89svtr96y1X2vtKR05tL_Px92ypZFoUjB788ioyr52CHXl6C5r8og9CFzES04XVd3LgSaMPvpWxDQMMi4JQCxo8QAloUeU2DN46Bc2WyynI3LMjiEUZtN3fltbc-J9jskl-BvywnZYF5opunqBdFPSyoDaTEbFUluDSZV5WIp27AkbMWexuMdIxmMYIggV-78";
  18. string loginPostStr = string.Format("username={0}&password={1}", "shotupbro", "kolombo123");
  19. string loginCookie;
  20. WebRequest req = WebRequest.Create(loginURL);
  21. req.ContentType = "application/x-www-form-urlencoded";
  22. req.Method = "POST";
  23. byte[] bytes = Encoding.ASCII.GetBytes(loginPostStr);
  24. req.ContentLength = bytes.Length;
  25. using (Stream os = req.GetRequestStream())
  26. {
  27. os.Write(bytes, 0, bytes.Length);
  28. }
  29. WebResponse resp = req.GetResponse();
  30. loginCookie = resp.Headers["Set-cookie"];
  31.  
  32. // working with cookie
  33.  
  34. string htmlSource;
  35. WebRequest getRequest = WebRequest.Create("https://de1.darkorbit.com/indexInternal.es?action=internalStart");
  36. getRequest.Headers.Add("Cookie", loginCookie);
  37. WebResponse getResponse = getRequest.GetResponse();
  38. using (StreamReader sr = new StreamReader(getResponse.GetResponseStream()))
  39. {
  40. htmlSource = sr.ReadToEnd();
  41. }
  42.  
  43. HtmlAgilityPack.HtmlDocument htmlDocument = new HtmlAgilityPack.HtmlDocument();
  44. htmlDocument.LoadHtml(htmlSource);
  45. var value1 = htmlDocument.DocumentNode.SelectSingleNode("//a[@id='header_uri']");
  46.  
  47.  
  48. Console.WriteLine(htmlSource);
  49. }
  50. }
  51. }
Add Comment
Please, Sign In to add comment