Beispiel #1
0
        /// <summary>
        /// POST从URL获取对象
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="url"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public static T FromUrl <T>(string url, string data)
        {
            var message = new RequestMessage {
                Url = url, PostData = data
            };

            if (Credence != null)
            {
                message.Cookies = Credence;
            }
            string webProxy = ConfigurationUtility.AppSettings <string>("WebProxy", string.Empty);

            if (!string.IsNullOrEmpty(webProxy))
            {
                message.Proxy = new WebProxy(webProxy);
            }
            var content = DownLoader.GetContent(message, 3);

            return(content.FromJson <T>());
        }