public IHtmlDocument Get(IWebUrl url) { WebRequest request = HttpWebRequest.Create(url.Url); using (WebResponse response = request.GetResponse()) { using (StreamReader reader = new StreamReader(response.GetResponseStream())) { HtmlDocument.DomDocument = new DomDocument(reader.ReadToEnd()); } } return HtmlDocument; }
public IHtmlDocument Post(IWebUrl url, IDictionary<string,string> postData) { WebRequest request = HttpWebRequest.Create(url.Url); request.Method = "POST"; using (Stream requestStream = request.GetRequestStream()) { Byte[] buffer = System.Text.Encoding.UTF8.GetBytes(PostDataConvertor.ParseObject(postData)); requestStream.Write(buffer, 0, buffer.Length); request.ContentLength = buffer.Length; using (WebResponse response = request.GetResponse()) { using (StreamReader reader = new StreamReader(response.GetResponseStream())) { HtmlDocument.DomDocument = new DomDocument(reader.ReadToEnd()); } } } return HtmlDocument; }