Exemplo n.º 1
0
        /// <summary>
        /// 获得网站的版本
        /// </summary>
        /// <returns></returns>
        public static string GetResourceVersion(out int code, out string err)
        {
            code = 0;
            err  = null;

            var client = new NetClient();
            var task   = client.RunRequestLoop(_ => client.Create <string>(HttpMethod.Get, NetworkEnvironment.UrlResourceVersion, ""), retryCount: 1);

            if (!task.IsValid() && task.Exception is SystemBusyException)
            {
                //网络繁忙,被封锁IP
                code = -2;
                err  = task.GetErrorMsg();

                return(null);
            }

            if (task != null && task.IsSuccess)
            {
                var text = task.Result;
                var m    = System.Text.RegularExpressions.Regex.Match(text, @"station_name\.js\?station_version=([\d\.]+)", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                if (m.Success)
                {
                    return(m.Groups[1].Value);
                }
            }
            code = -1;
            err  = task.GetErrorMsg();

            return(null);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获得站点JS的内容
        /// </summary>
        /// <returns></returns>
        public static string GetCityNameJsContent(out string err)
        {
            err = null;

            var client = new NetClient();
            var task   = client.RunRequestLoop(_ => client.Create <string>(HttpMethod.Get, NetworkEnvironment.UrlScriptCityName));

            if (task != null && task.IsSuccess)
            {
                return(task.Result);
            }

            err = task.GetErrorMsg();
            return(null);
        }