Esempio n. 1
0
        private void fun_unknown()
        {
            string str = @"https://lbs.gtimg.com/maplbs/qianxi/00000000/37010006.js";

            WebClientto client = new WebClientto(4500);

            client.Encoding = Encoding.UTF8;
            client.Headers.Add("Content-Type", "application/x-www-form-urlencoded");

            Stream stream   = null;
            string str_json = null;

            stream = client.OpenRead(str);

            str_json = new StreamReader(stream).ReadToEnd();

            Regex regexObj = new Regex(@"\[(?<result>)[^[\]]+\]");

            System.Text.RegularExpressions.Match matchResult = regexObj.Match(str_json);
            while (matchResult.Success)
            {
                MessageBox.Show(matchResult.Groups[0].Value);
                matchResult = matchResult.NextMatch();
            }
        }
Esempio n. 2
0
        public static dynamic GetWebApi(string uri, int timeOut = 3000)
        {
            string    result = string.Empty;
            WebClient client = new WebClientto(timeOut);

            System.IO.Stream       stream = client.OpenRead(uri);
            System.IO.StreamReader reader = new System.IO.StreamReader(stream, System.Text.Encoding.UTF8);
            result = reader.ReadToEnd();
            reader.Close();
            return(JsonConvert.DeserializeObject(result));
        }
Esempio n. 3
0
        public async static Task <ResponseObject> GetWebApiAsync(string uri, int timeOut = 3000)
        {
            string    result = string.Empty;
            WebClient client = new WebClientto(timeOut);

            System.IO.Stream       stream = client.OpenRead(uri);
            System.IO.StreamReader reader = new System.IO.StreamReader(stream, System.Text.Encoding.UTF8);
            result = await reader.ReadToEndAsync();

            reader.Close();
            return(new ResponseObject(true, JsonConvert.DeserializeObject(result)));
        }