using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;

namespace RFrameGenerate.Common
{
     public class DowloadingImage
    {
        public static Image Request(string url)
        {
            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                request.Proxy = null;
                request.ContentType = "application/x-www-form-urlencoded";
                request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
                request.KeepAlive = true;
                request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.57 Safari/537.36";
                using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
                {
                    return Image.FromStream(response.GetResponseStream());
                }
            }
            catch (Exception ex)
            {
                return null;
            }
        }
    }
}
