public async Task TestMethod1() { // delete table StorageAccount .CreateCloudTableClient() .GetTableReference(TableName) .DeleteIfExists(); // load, parse var client = new DmmGameRankingClient(); var html = File.ReadAllText(LocalHtmlPath); await client.LoadFromHtmlAsync(html); var elements = client.Parse(); elements.Any().IsTrue(); var tableClient = new DmmGameRankingTableClient(StorageAccount, TableName); var nowStr = DateTime.Now.ToString("yyyyMMdd_HHmmss"); var entities = elements.Select(x => new DmmGameRankingEntity { GameTitle = x.Name, ObservedDateTime = nowStr, Rank = x.Rank, Genre = x.Genre, Comment = x.Comment, }); await tableClient.AddOrUpdateAsync(entities); }
public static async Task Run([TimerTrigger("0 10 */1 * * *")] TimerInfo myTimer, TraceWriter log) { log.Info($"C# Timer trigger function executed at: {DateTime.Now}"); var nowStr = DateTime.Now.ToString("yyyyMMdd_HHmmss"); log.Info($"nowStr: {nowStr}"); var dmmClient = new DmmGameRankingClient(); log.Info($"dmmClient.LoadFromWebAsync()"); await dmmClient.LoadFromWebAsync(); log.Info($"dmmClient.Parse()"); var rakingData = dmmClient.Parse(); log.Info($"new tableClient"); var tableClient = new DmmGameRankingTableClient(StorageAccount, TableName); log.Info($"mapping rankingData to entity"); var entities = rakingData.Select(x => new DmmGameRankingEntity { GameTitle = x.Name, ObservedDateTime = nowStr, Rank = x.Rank, Genre = x.Genre, Comment = x.Comment, }); log.Info($"tableClient.AddOrUpdateAsync(entities)"); await tableClient.AddOrUpdateAsync(entities); log.Info($"finished!!"); }
public async Task ParseTest() { var client = new DmmGameRankingClient(); var html = File.ReadAllText(LocalHtmlPath); await client.LoadFromHtmlAsync(html); var elements = client.Parse(); elements.Any().IsTrue(); }