public static string dkm() { string urlAddress = "http://truyentranh8.com/con-pho-noi-ta-yeu/"; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(urlAddress); request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"; request.Headers.Add("Accept-Encoding","gzip,deflate,sdch"); request.Headers.Add("Cache-Control", "max-age=0"); request.Host = "truyentranh8.com"; request.Method = "GET"; request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate; request.KeepAlive = false; request.UserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.103 Safari/537.36"; request.ReadWriteTimeout = 100000; request.Timeout = 100000; try { HttpWebResponse response = (HttpWebResponse)request.GetResponse(); if (response.StatusCode == HttpStatusCode.OK) { Stream receiveStream = response.GetResponseStream(); StreamReader readStream = null; if (response.CharacterSet == null) readStream = new StreamReader(receiveStream); else readStream = new StreamReader(receiveStream, Encoding.GetEncoding(response.CharacterSet)); string data = readStream.ReadToEnd(); response.Close(); readStream.Close(); } } catch(WebException we) { var test = we.InnerException; HttpWebResponse errorResponse = we.Response as HttpWebResponse; var fuck1 = errorResponse.GetLifetimeService(); if (errorResponse.StatusCode == HttpStatusCode.NotFound) { // Encoding encode = System.Text.Encoding.GetEncoding("utf-8"); var Stream = new StreamReader(errorResponse.GetResponseStream()); while (Stream.Peek() >= 0) { Console.WriteLine(Stream.ReadLine()); } } } return ""; }