private string DownloadSource(NineGAGSection section) { var sectionLinkAddition = ""; //Enum selection switch (section) { case NineGAGSection.Fresh: sectionLinkAddition = "fresh"; break; case NineGAGSection.Trending: sectionLinkAddition = "trending"; break; case NineGAGSection.Hot: sectionLinkAddition = "hot"; break; } //Webrequest WebRequest req = HttpWebRequest.Create("https://9gag.com/" + sectionLinkAddition); req.Method = "GET"; string source; using (StreamReader reader = new StreamReader(req.GetResponse().GetResponseStream())) { source = reader.ReadToEnd(); } return(source); }
public Bitmap GetMeme(NineGAGSection section) { Bitmap temp = null; var source = DownloadSource(section); GetMatches(source); while (temp == null && pictureUrls.Count != 0) { temp = DownloadImage(GetRandomPictureUrl()); } return(temp); }