예제 #1
0
        public void StorePoolData()
        {
            HttpClient          http             = new HttpClient();
            var                 str              = http.GetAsync($@"http://www.wabi.com/coins/conflux").Result.Content.ReadAsStringAsync().Result;
            Regex               regex            = new Regex("_blank\">(.+?)<\\/a>[\\s\\S]{3,100}data-sort=\"(\\d+)\"");
            List <PoolHashRate> poolHashRateList = new List <PoolHashRate>();
            var                 now              = DateTime.Now;

            foreach (Match match in regex.Matches(str))
            {
                var poolName     = match.Groups[1].Value;
                var hashRate     = match.Groups[2].Value;
                var poolHashRate = new PoolHashRate
                {
                    CreatedAt = now,
                    Hashrate  = Convert.ToInt64(hashRate),
                    Name      = poolName,
                };
                poolHashRateList.Add(poolHashRate);
            }
            str   = http.GetAsync($@"https://confluxscan.io/v1/plot?interval=514&limit=1").Result.Content.ReadAsStringAsync().Result;
            regex = new Regex("\"hashRate\":\"([\\d]+)");

            poolHashRateList.Add(new PoolHashRate
            {
                CreatedAt = now,
                Hashrate  = Convert.ToInt64(regex.Match(str).Groups[1].Value),
                Name      = "All",
            });
            transactionRepository.AddPoolHashRate(poolHashRateList);
        }