Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using (HttpClientHandler handler = new HttpClientHandler() { AllowAutoRedirect = true, AutomaticDecompression = System.Net.DecompressionMethods.GZip | System.Net.DecompressionMethods.Deflate })
- {
- using (HttpClient client = new HttpClient(handler) { BaseAddress = new Uri(url) })
- {
- HtmlAgilityPack.HtmlDocument HD = new HtmlAgilityPack.HtmlDocument();
- HD.LoadHtml(client.GetStringAsync(complUrl).Result); //можно делать все асинхронно.
- var sizerut = HD.DocumentNode.SelectSingleNode("//tr[@class='row1']");//искомый элемент
- }
- }
- HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.rutracker.org/forum/login.php");
- request.Method = "POST";
- string data = "login_username=логин&password=пароль&login=go";
- byte[] byteData = Encoding.UTF8.GetBytes(data);
- request.ContentLength = byteData.Length;
- Stream stream = request.GetRequestStream();
- stream.Write(byteData, 0, byteData.Length);
- request.CookieContainer = new CookieContainer();
- string response = new StreamReader(request.GetResponse().GetResponseStream()).ReadToEnd();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement