Advertisement
Guest User

Untitled

a guest
May 1st, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. using (HttpClientHandler handler = new HttpClientHandler() { AllowAutoRedirect = true, AutomaticDecompression = System.Net.DecompressionMethods.GZip | System.Net.DecompressionMethods.Deflate })
  2. {
  3. using (HttpClient client = new HttpClient(handler) { BaseAddress = new Uri(url) })
  4. {
  5.  
  6. HtmlAgilityPack.HtmlDocument HD = new HtmlAgilityPack.HtmlDocument();
  7. HD.LoadHtml(client.GetStringAsync(complUrl).Result); //можно делать все асинхронно.
  8. var sizerut = HD.DocumentNode.SelectSingleNode("//tr[@class='row1']");//искомый элемент
  9. }
  10. }
  11.  
  12. HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.rutracker.org/forum/login.php");
  13.  
  14.  
  15. request.Method = "POST";
  16. string data = "login_username=логин&password=пароль&login=go";
  17. byte[] byteData = Encoding.UTF8.GetBytes(data);
  18. request.ContentLength = byteData.Length;
  19. Stream stream = request.GetRequestStream();
  20. stream.Write(byteData, 0, byteData.Length);
  21. request.CookieContainer = new CookieContainer();
  22. string response = new StreamReader(request.GetResponse().GetResponseStream()).ReadToEnd();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement