private List <categorymembers> getCategoryTree(String categoryName) { string url = urlWikipedia + categoryName + "&cmlimit=500&format=json&utf8="; var webClient = new WebClient(); var pageSourceCode = webClient.DownloadString(url); byte[] bytes = Encoding.Default.GetBytes(pageSourceCode); String myString = Encoding.UTF8.GetString(bytes); CategoriesList SubCategoriesList = JsonConvert.DeserializeObject <CategoriesList>(myString); return(SubCategoriesList.query.getCategorymembersList()); }
private CategoriesList getSubCatgories(CategoriesList mainlistCategories) { categorymembers subCategori = mainlistCategories.query.getRendomCategory(); string url = urlWikipedia + subCategori.title + "&cmlimit=500&format=json&utf8="; var webClient = new WebClient(); var pageSourceCode = webClient.DownloadString(url); byte[] bytes = Encoding.Default.GetBytes(pageSourceCode); String myString = Encoding.UTF8.GetString(bytes); CategoriesList SubCategoriesList = JsonConvert.DeserializeObject <CategoriesList>(myString); return(SubCategoriesList); }
public void StartHistoryRendom(String title) { categoryList = new List <CategoryTree>(); var webClient = new WebClient(); string url = urlWikipedia + title + "&cmlimit=500&format=json&utf8="; var pageSourceCode = webClient.DownloadString(url); byte[] bytes = Encoding.Default.GetBytes(pageSourceCode); String myString = Encoding.UTF8.GetString(bytes); CategoriesList mainlistCategories = JsonConvert.DeserializeObject <CategoriesList>(myString); List <categorymembers> cm = mainlistCategories.query.getCategorymembersList(); CategoryTree tr = new CategoryTree(); tr.CatgoryName = title; tr.PagesList = cm; categoryList.Add(tr); do { String categoryName = getRendomeCatgoryTitle(cm); if (categoryName.Equals("notfind")) { break; } cm = getCategoryTree(categoryName); CategoryTree tree = new CategoryTree(); tree.CatgoryName = categoryName; tree.PagesList = cm; categoryList.Add(tree); } while (true); Pagename page = getRendomPage(); startHtml(page); }