public HttpResponseMessage GetRandom() { string htmlString = VineScopeHtmlRequester("random.php"); if (htmlString == null) { return(this.Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Server is down")); } var htmlDocument = new HtmlDocument(); htmlDocument.LoadHtml(htmlString); var indexVideoNode = htmlDocument.GetElementbyId("container").SelectSingleNode("div"); Vine vine = Vine.Parse(indexVideoNode); vine.Url = Vine.GetUrl(vine); return(this.Request.CreateResponse(HttpStatusCode.OK, vine)); }
public HttpResponseMessage Get() { string htmlString = VineScopeHtmlRequester(); if (htmlString == null) { return(this.Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Server is down")); } var htmlDocument = new HtmlDocument(); htmlDocument.LoadHtml(htmlString); var indexVideoNode = htmlDocument.GetElementbyId("container").SelectSingleNode("div"); VineThumbnail indexMainVine = Vine.Parse(indexVideoNode); indexMainVine.Url = Vine.GetUrl(indexMainVine); var vines = new List <VineThumbnail>(); vines.Add(indexMainVine); var featuredVinesNodes = htmlDocument.GetElementbyId("container") .SelectNodes("div/div/div") .Where(n => n.Attributes["class"] != null && n.Attributes["class"].Value == "thumb-list") .FirstOrDefault() .SelectNodes("article"); foreach (var node in featuredVinesNodes) { var vine = VineThumbnail.Parse(node); vine.Url = vine.Url.Substring(vine.Url.LastIndexOf("/") + 1); vines.Add(vine); } return(this.Request.CreateResponse(HttpStatusCode.OK, vines)); }