public ActionResult GetBoardList() { BoardListModel result = new BoardListModel(); try { BasePtt basePtt = new BasePtt(); var res = basePtt.RequestPtt("bbs/index.html"); var htmlDoc = new HtmlDocument(); htmlDoc.LoadHtml(res); var board = htmlDoc.DocumentNode.SelectNodes("//a[@class='board']"); var detail = board.Select(item => item.SelectNodes("div")); result = new BoardListModel() { Status = "OK", Msg = "", Data = detail.Select(item => new BoardList() { BoardID = item[0].InnerText, VisitCount = item[1].ChildNodes[0].InnerText, BoardType = item[2].InnerText, BoardHeader = item[3].InnerText }).ToList() }; } catch (Exception ex) { result.Status = "NG"; result.Msg = ex.Message; } return(Json(result, JsonRequestBehavior.AllowGet)); }
public async Task <BoardInfo> GetBoardInfoAsync() { if (_cachedBoardInfo != null) { return(_cachedBoardInfo); } if (_cachedBoardList == null) { string json = await Internet.DownloadString(@"https://a.4cdn.org/boards.json").ConfigureAwait(false); _cachedBoardList = JsonDeserializer.Deserialize <BoardListModel>(json); } _cachedBoardInfo = _cachedBoardList.Boards.FirstOrDefault(b => b.ShortName == BoardId); return(_cachedBoardInfo); }