public Task GetSteamInventory(string steamId) { string steamInventoryUrl = SteamConst.SteamInventoryUrl(steamId); var webClient = new WebClient(); string requestResult = webClient.DownloadString(steamInventoryUrl); var fileResult = File.ReadAllText(@"H:\Works\Project\Core\TradeBot\json.txt"); var itemDto = JsonConvert.DeserializeObject <SteamInventoryDto>(fileResult); throw new NotImplementedException(); }
public async Task <T> GetByName(string name, T model) { string encodeName = HttpUtility.UrlEncode(name, Encoding.UTF8); encodeName = encodeName.Replace("+", "%20"); // Replace space to code string steamItemUrl = SteamConst.GeneralSteamItemUrl(encodeName); seleniumWebDriver.GoToUrl(steamItemUrl); string pageSource = seleniumWebDriver.ChromeDriver.PageSource; // Find id string pattern = @"(?<=Market_LoadOrderSpread\()(.*?)(?=\))"; model.GeneralId = Regex.Match(pageSource, pattern).Value.Trim(); await GetPriceById(model.GeneralId, model); return(model); }
public async Task <T> GetPriceById(string id, T model) { string steamItemUrl = SteamConst.InfoSteamItemUrl(id); var webClient = new WebClient(); string requestResult = webClient.DownloadString(steamItemUrl); var itemDto = JsonConvert.DeserializeObject <SteamItemBaseDto>(requestResult); if (itemDto.IsSucccess) { FillPriceInModel(itemDto, model); } else { throw new ItemNotFoundException($"Item with this Id: {id} was not found at Steam market"); } return(model); }
/// <summary> /// Return only Price and CountBySellPrice /// </summary> /// <param name="name"></param> /// <param name="model"></param> /// <returns></returns> public async Task <T> GetShortPriceInfoByName(string name, T model) { string encodeName = HttpUtility.UrlEncode(name, Encoding.UTF8); encodeName = encodeName.Replace("+", "%20"); // Replace space to code string steamItemUrl = SteamConst.PriceSteamItemUrl(encodeName); var webClient = new WebClient(); string requestResult = webClient.DownloadString(steamItemUrl); var itemDto = JsonConvert.DeserializeObject <SteamShortPriceDto>(requestResult); if (itemDto.IsSuccess) { model.Price = Convert.ToDouble(itemDto.LowestPrice); model.SaleCount = Convert.ToInt32(itemDto.Volume); } return(model); }