/// <summary>
        /// Send a GET request to a web page. Returns the contents of the page.
        /// </summary>
        /// <param name="url">The address to GET.</param>
        public string Get(string url, ProxySettings settings)
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

            // Use a proxy
            if (settings.UseProxy)
            {
                IWebProxy proxy = request.Proxy;
                WebProxy myProxy = new WebProxy();
                Uri newUri = new Uri(settings.ProxyAddress);

                myProxy.Address = newUri;
                myProxy.Credentials = new NetworkCredential(settings.ProxyUsername, settings.ProxyPassword);
                request.Proxy = myProxy;
            }

            request.Method = "GET";
            request.CookieContainer = cookies;
            WebResponse response = request.GetResponse();
            StreamReader sr = new StreamReader(response.GetResponseStream(), System.Text.Encoding.UTF8);
            string result = sr.ReadToEnd();
            sr.Close();
            response.Close();

            return result;
        }
 /// <summary>
 /// Send a GET request to a web page. Returns the contents of the page.
 /// </summary>
 /// <param name="url">The address to GET.</param>
 public string Get(string url)
 {
     ProxySettings settings = new ProxySettings() { UseProxy = false };
     return Get(url, settings);
 }
        /// <summary>
        /// Send a POST request to a web page. Returns the contents of the page.
        /// </summary>
        /// <param name="url">The address to POST to.</param>
        /// <param name="data">The data to POST.</param>
        public string Post(string url, string data, ProxySettings settings)
        {
            try
            {
                byte[] buffer = Encoding.ASCII.GetBytes(data);
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

                // Use a proxy
                if (settings.UseProxy)
                {
                    IWebProxy proxy = request.Proxy;
                    WebProxy myProxy = new WebProxy();

                    Uri newUri = new Uri(settings.ProxyAddress);
                    myProxy.Address = newUri;

                    myProxy.Credentials = new NetworkCredential(settings.ProxyUsername, settings.ProxyPassword);
                    request.Proxy = myProxy;
                }

                // Send request
                request.Method = "POST";
                request.ContentType = "application/x-www-form-urlencoded";
                request.ContentLength = buffer.Length;
                request.CookieContainer = cookies;
                Stream postData = request.GetRequestStream();
                postData.Write(buffer, 0, buffer.Length);
                postData.Close();

                // Get and return response
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                Stream Answer = response.GetResponseStream();
                StreamReader answer = new StreamReader(Answer);
                return answer.ReadToEnd();
            }
            catch (Exception ex)
            {
                return "ERROR: " + ex.Message;
            }
        }
 /// <summary>
 /// Send a POST request to a web page. Returns the contents of the page.
 /// </summary>
 /// <param name="url">The address to POST to.</param>
 /// <param name="data">The data to POST.</param>
 public string Post(string url, string data)
 {
     ProxySettings settings = new ProxySettings() { UseProxy = false };
     return Post(url, data, settings);
 }
 /// <summary>
 /// Send a POST request to a web page. Returns the contents of the page.
 /// </summary>
 /// <param name="url">The address to POST to.</param>
 /// <param name="postVars">The list of variables to POST to the server.</param>
 public string Post(string url, PostPackageBuilder postVars)
 {
     ProxySettings settings = new ProxySettings() { UseProxy = false };
     return Post(url, postVars.PostDataString, settings);
 }
 /// <summary>
 /// Send a POST request to a web page. Returns the contents of the page.
 /// </summary>
 /// <param name="url">The address to POST to.</param>
 /// <param name="postVars">The list of variables to POST to the server.</param>
 public string Post(string url, PostPackageBuilder postVars, ProxySettings settings)
 {
     return Post(url, postVars.PostDataString, settings);
 }
 /// <summary>
 /// Send a POST request to a web page. Returns the contents of the page.
 /// </summary>
 /// <param name="url">The address to POST to.</param>
 /// <param name="postVars">The list of variables to POST to the server.</param>
 public string Post(string url, PostPackageBuilder postVars, ProxySettings settings)
 {
     return(Post(url, postVars.PostDataString, settings));
 }