static async Task <bool> MainAsync() { Wikipedia wikipedia = new Wikipedia(); await wikipedia.GetSectionData("Plant"); return(true); }
public async Task WikiAsync([Remainder][Summary("Article name")] string article) { Wikipedia wikipedia = new Wikipedia { Limit = 5 }; await RankaReplyAsync($"Searching Wikipedia for {article}....").ConfigureAwait(false); QueryResult results = wikipedia.Search($"{article}"); await _chrome.NewBrowserAsync(2000).ConfigureAwait(false); BasicScreenshot chrome = new BasicScreenshot(results.Search.ElementAt(0).Url.AbsoluteUri); await RankaReplyAsync("Taking screenshot...").ConfigureAwait(false); var file = await chrome.GetScreenshot(_chrome.GetChromiumPage()).ConfigureAwait(false); await RankaReplyAsync($"Done, here's your screenshot!").ConfigureAwait(false); await RankaFileUploadAsync(file).ConfigureAwait(false); await chrome.Cleanup(_chrome.GetChromiumPage()).ConfigureAwait(false); await _chrome.Destroy().ConfigureAwait(false); }
public void WikiAllImages() { Wikipedia wiki1 = new Wikipedia(driver); wiki1.GoToSite(); wiki1.MakeAllImagesScreen(); }
private List <SearchResult> SearchGames(string keyword, MetadataProvider provider) { var searchList = new List <SearchResult>(); switch (provider) { case MetadataProvider.Wiki: var wiki = new Wikipedia(); foreach (var page in wiki.Search(keyword)) { searchList.Add(new SearchResult(page.title, page.title, page.snippet)); } break; case MetadataProvider.IGDB: var igdb = new IGDB(); foreach (var page in igdb.Search(keyword)) { searchList.Add(new SearchResult(page.id.ToString(), page.name, string.Empty)); } break; } return(searchList); }
public void WikiContainer() { Wikipedia wiki = new Wikipedia(driver); wiki.goToSite(); wiki.makeDidYoyKnowScreen(); wiki.makeInTheNewsContainerScreen(); }
public async Task WikiSearchAsync([Remainder][Summary("Article name")] string article) { Wikipedia wikipedia = new Wikipedia { Limit = 5 }; await RankaReplyAsync($"Searching Wikipedia for {article}....").ConfigureAwait(false); QueryResult results = wikipedia.Search($"{article}"); EmbedBuilder emb = new EmbedBuilder { Author = new EmbedAuthorBuilder { Name = "Wikipedia", IconUrl = "https://upload.wikimedia.org/wikipedia/commons/f/ff/Wikipedia_logo_593.jpg" }, Title = $"Search results for {article}", Color = Color.LightGrey, Footer = new EmbedFooterBuilder { Text = "Wikipedia for Ranka" } }; foreach (var item in results.Search) { emb.AddField(item.Title, item.Url.AbsoluteUri); } await RankaReplyAsync(emb).ConfigureAwait(false); }
public IActionResult GetWikiUrl(string author) { Wikipedia wikipedia = new Wikipedia(); string UrlFound = null; QueryResult results = wikipedia.Search(author); UrlFound = results.Search[0].Url.AbsoluteUri; return(Redirect(UrlFound)); }
//The array creates on awake so it can pull value from rowLength////////////////// void Awake() { wiki = GameObject.Find("Wikipedia").GetComponent <Wikipedia>(); Player = GameObject.Find("Player").GetComponent <DicePrefeb>(); aRow = new DicePrefeb[rowLength]; bRow = new DicePrefeb[rowLength]; readWiki(); Populate(); }
public void JsonStringShouldReturnDescription() { JsonTextReader reader = new JsonTextReader(new StringReader(jsonString)); WikipediaSerializer wikipediaSerializer = new WikipediaSerializer(); Wikipedia wikipedia = wikipediaSerializer.Deserialize(reader, "https://en.wikipedia.org/w/api.php?action=query&format=json&prop=extracts&exintro=true&redirects=true&titles=Nirvana_(band)"); // TODO expand this test Assert.NotNull(wikipedia.Description); }
static void Main(string[] args) { Wikipedia wClass = new Wikipedia(new WikiQueryEngine()); Console.WriteLine(wClass.IsArticleAvailable("DDLJ")); SearchSuggestion searchSuggest = wClass.SearchArticles("DDLJ", 10); foreach (SearchSuggestionItem sItem in searchSuggest.Section) { Console.WriteLine(sItem.Text + "\n\t" + sItem.Description + "\n" + sItem.Url); } Console.WriteLine(wClass.GetArticle("Seattle",false).Introduction); return; }
public async Task Wiki(string langcode, [Remainder] string query) { var page = await Wikipedia.GetArticleAsync(langcode, query).ConfigureAwait(false); var embed = new EmbedBuilder() .WithAuthor(page.Name, url: page.Url) .WithRandomColor(); embed.AddField("Description", page.Description ?? "Not Available", true); await embed.QueueMessageAsync(Context).ConfigureAwait(false); }
public void TestMethod_GetAllFilesNames() { var wiki = new Wikipedia { List = ListType.Geosearch, Format = Format.Json, Limit = 50 }; wiki.ExternParameters.AddRange(new List <Tuple <string, object> >() { new Tuple <string, object>("gsradius", 10000), new Tuple <string, object>("gscoord", string.Join("|", new[] { 37.786971, -122.399677 })) }); var responce = wiki.Search <GeoRootObject>(null); TextWriter fileRaw = File.CreateText(DateTime.Now.ToString("yyMMddhhss") + "Raw.txt"); TextWriter file = File.CreateText(DateTime.Now.ToString("yyMMddhhss") + ".txt"); List <Tuple <int, string> > wikiImages = new List <Tuple <int, string> >(); foreach (Geosearch geosearch in responce.Query.GeoSearch) { var wikiFile = new Wikipedia { Format = Format.Json }; wikiFile.ExternParameters.AddRange(new List <Tuple <string, object> >() { new Tuple <string, object>("prop", "images"), new Tuple <string, object>("pageids", geosearch.PageId) }); var responceFile = wikiFile.Search <ImagesRootObject>(null); wikiImages.AddRange(from images in responceFile.Query.Pages.Values from image in images.Images select new Tuple <int, string>(geosearch.PageId, image.Title.Replace("File:", ""))); } foreach (var t in wikiImages) { fileRaw.WriteLine($"{t.Item1}; {t.Item2}"); } for (int i = 0; i < wikiImages.Count; i++) { for (int j = i + 1; j < wikiImages.Count; j++) { var res = Shingle.CulculateSimple(wikiImages[i].Item2, wikiImages[j].Item2); if (res > 0 && res < 1) { file.WriteLine($"{wikiImages[i].Item1}; {wikiImages[j].Item1}; {(int)(res*10000)}; {wikiImages[i].Item2}; {wikiImages[j].Item2};"); } } } }
//obter retorno em json direto da wikipedia //a wikipedia tem um GET para JSON formatável //retornar a lista ==> list=search //https://en.wikipedia.org/w/api.php?format=json&action=query&generator=search&gsrnamespace=0&gsrsearch=jair%20bolsonaro&gsrlimit=10&list=search|extracts&pilimit=max&exintro&explaintext&exsentences=1&exlimit=max //retornar as imagens => prop=pageimages //https://en.wikipedia.org/w/api.php?format=json&action=query&generator=search&gsrnamespace=0&gsrsearch=jair%20bolsonaro&gsrlimit=10&prop=pageimages|extracts&pilimit=max&exintro&explaintext&exsentences=1&exlimit=max //retornar o conteudo => prop=extracts //https://en.wikipedia.org/w/api.php?format=json&action=query&generator=search&gsrnamespace=0&gsrsearch=jair%20bolsonaro&gsrlimit=10&prop=extracts|extracts //TODO: tem que ver o formato certo, como define linguagem, etc public static string SimpleSearch(string query) { Wikipedia wiki = new Wikipedia(); wiki.Limit = 5; wiki.Language = WikipediaNet.Enums.Language.Portuguese; QueryResult results = wiki.Search(query); return(JsonConvert.SerializeObject(results, Formatting.Indented)); }
private void PrintName(GameObject go) { Debug.Log(go.name); GameObject canvas = gameObject.transform.Find("Canvas").gameObject; GameObject canvasAtom = gameObject.transform.Find("CanvasAtom").gameObject; if (canvas.activeSelf == true) { canvas.SetActive(false); } canvasAtom.SetActive(true); datascript = GetComponent <AtomDataScript>(); wiki = GetComponent <Wikipedia>(); var modelList = datascript.Atoms; //Text text = GameObject.Find("AR Session Origin/Canvas/Text").GetComponent<Text>(); //text.text = go.name; Atom model = modelList.Find(m => m.ShortName == go.name); //var tagname = gameObject.tag; Text atom = GameObject.Find("AR Session Origin/CanvasAtom/Atominfo/Atom").GetComponent <Text>(); atom.text = model.ShortName; Text title = GameObject.Find("AR Session Origin/CanvasAtom/Atominfo/Title").GetComponent <Text>(); title.text = model.Name; Text weight = GameObject.Find("AR Session Origin/CanvasAtom/Atominfo/Weight").GetComponent <Text>(); weight.text = model.Weight; Text number = GameObject.Find("AR Session Origin/CanvasAtom/Atominfo/Number").GetComponent <Text>(); number.text = model.Number; Text infoAtom = GameObject.Find("AR Session Origin/CanvasAtom/AtomInfoFull").GetComponent <Text>(); infoAtom.text = model.Description.Substring(0, 90) + "..."; //wikipedia link wiki.URL = model.WikipediaLink; //proberen met playerpref PlayerPrefs.SetString("WikiLink", wiki.URL); }
public async Task <QueryResult> CallWikipedia(string utterance) { //Default language is English var wikipedia = new Wikipedia { UseTLS = true, Limit = 5, What = What.Text, Language = Language.French }; var searchText = utterance; var results = wikipedia.Search(searchText); return(results); }
public void W02_Find_Article() { //поиск статьи внутри самой Википедии driver.Navigate().GoToUrl("https://uk.wikipedia.org"); Thread.Sleep(2000); Wikipedia wikiPage = new Wikipedia(); PageFactory.InitElements(driver, wikiPage); wikiPage.SearchField.SendKeys("Test case"); Thread.Sleep(1000); wikiPage.SearchButton.Click(); wikiPage.ArticleLink.Click(); Thread.Sleep(2000); Assert.AreEqual("Тестовий випадок — Вікіпедія", driver.Title); Thread.Sleep(2000); }
/// <summary> /// /// </summary> /// <param name="query"></param> /// <returns></returns> private Object GetSource(String query) { try { if (String.IsNullOrEmpty(query)) { return(null); } Wikipedia wiki = new Wikipedia(new WikiQueryEngine()); SearchSuggestion suggestion = wiki.SearchArticles(query, 10); WikiControl omukControl = new WikiControl(); return(suggestion); } catch { } return(null); }
static void Main(string[] args) { //Default language is English Wikipedia wikipedia = new Wikipedia(); //Use HTTPS instead of HTTP wikipedia.UseTLS = true; //We would like 5 results wikipedia.Limit = 5; //We would like to search inside the articles wikipedia.What = What.Text; const string searchText = "Microsoft C#"; QueryResult results = wikipedia.Search(searchText); Console.WriteLine("Searching for {0}:{1}", searchText, Environment.NewLine); Console.WriteLine("Found " + results.Search.Count + " English results:"); foreach (Search s in results.Search) { Console.WriteLine(s.Title); } Console.WriteLine(); Console.WriteLine(); //We change the language to Spanish wikipedia.Language = Language.Spanish; results = wikipedia.Search("Microsoft C#"); Console.WriteLine("Found " + results.Search.Count + " Spanish results:"); foreach (Search s in results.Search) { Console.WriteLine(s.Title); } Console.WriteLine("Press a key to continue"); Console.ReadLine(); }
public void TestMethod_GetImages() { var wiki = new Wikipedia { Format = Format.Json }; wiki.ExternParameters.AddRange(new List <Tuple <string, object> >() { new Tuple <string, object>("prop", "images"), new Tuple <string, object>("pageids", 18618509) }); var responce = wiki.Search <ImagesRootObject>(null); Assert.IsNotNull(responce); Assert.IsTrue(responce.Query.Pages.Values.First().Images.Count > 0); }
public async Task wiki(params String[] name) { string output = new Addons()._out(name); Wikipedia w = new Wikipedia(); w.UseTLS = true; w.Limit = 1; w.What = What.Text; QueryResult response = w.Search(output); if (response.Search[0].Url.ToString() != "https://en.wikipedia.org/wiki/") { await Context.Channel.SendMessageAsync(response.Search[0].Url.ToString().Replace(' ', '_')); } else { await Context.Channel.SendMessageAsync(":x: **No articles were found.**"); } }
private void OnTriggerEnter(Collider collider_) { d = GetComponent <DataScript>(); w = GetComponent <Wikipedia>(); Debug.Log(w.URL); var modelList = d.Models; if (collider_.gameObject.tag == "ARCamera") { Debug.Log("MoleculeLoaded"); GameObject plane = GameObject.Find("Plane"); if (plane.activeSelf == true) { plane.SetActive(false); } Model model = modelList.Find(m => m.ShortName == gameObject.tag); var tagname = gameObject.tag; Text formule = GameObject.Find("AR Session Origin/Canvas/Formule").GetComponent <Text>(); formule.text = model.ShortName; Text solidState = GameObject.Find("AR Session Origin/Canvas/Solid-State/Solid-State-info").GetComponent <Text>(); solidState.text = model.Solid; Text liquidState = GameObject.Find("AR Session Origin/Canvas/Liquid-State/Liquid-State-info").GetComponent <Text>(); liquidState.text = model.Liquid; Text gasState = GameObject.Find("AR Session Origin/Canvas/Gas-State/Gas-State-info").GetComponent <Text>(); gasState.text = model.Gas; Text infoMolecule = GameObject.Find("AR Session Origin/Canvas/Info").GetComponent <Text>(); infoMolecule.text = model.Description.Substring(0, 90) + "..."; //wikipedia link w.URL = model.WikipediaLink; //proberen met playerpref PlayerPrefs.SetString("WikiLink", w.URL); } }
public void TestMethod_GetGeoItems() { var wiki = new Wikipedia { List = ListType.Geosearch, Format = Format.Json, Limit = 50 }; wiki.ExternParameters.AddRange(new List <Tuple <string, object> >() { new Tuple <string, object>("gsradius", 10000), new Tuple <string, object>("gscoord", string.Join("|", new[] { 37.786971, -122.399677 })) }); var responce = wiki.Search <GeoRootObject>(null); Assert.IsNotNull(responce); Assert.AreEqual(50, responce.Query.GeoSearch.Count); }
private ArtistViewModel buildAlbumViewModel(Musicbrainz musicbrainz, Wikipedia wikipedia, IList <CoverartArchive> coverarts) { ArtistViewModel artistViewModel = new ArtistViewModel(); artistViewModel.Albums = new List <AlbumViewModel>(); artistViewModel.MBID = musicbrainz.MBID; artistViewModel.Description = wikipedia.Description; foreach (var album in musicbrainz.Albums) { artistViewModel.Albums.Add(new AlbumViewModel() { Id = album.Id, Title = album.Title, Image = coverarts.FirstOrDefault(x => x.Id == album.Id)?.Image }); } return(artistViewModel); }
public Search(string query) { var google = Google.FromQuery(query); var results = google.ResponseData.Results; var lucky = results[0]; Link = lucky.Url; Description = lucky.Content.StripHtml(); var result = results.FirstOrDefault(o => o.Url.ToLower().Contains("imdb")); if(result != null) { var imdb = IMDB.FromQuery(query); Source = "IMDB"; if (imdb.Response == "False") { Description = "Movie not found"; return; } Description = "{0} is a movie rated {1} by IMDB. It came out in {2} and the synopsis reads: {3}".Template( imdb.Title, imdb.ImdbRating, imdb.Released, imdb.Plot); Link = imdb.Page; return; } result = results.FirstOrDefault(o => o.Url.ToLower().Contains("wikipedia")); if(result != null) { Source = "Wikipedia"; Description = new Wikipedia(result.Url) + Environment.NewLine; Link = result.Url; } ToastView.Create(Description, Source, false); }
private void ButtonOK_Click(object sender, RoutedEventArgs e) { var id = ((SearchResult)ListSearch.SelectedItem).Id; Task.Factory.StartNew(() => { TextDownloading.Dispatcher.Invoke(() => { ListSearch.Visibility = Visibility.Hidden; TextDownloading.Visibility = Visibility.Visible; ButtonOK.IsEnabled = false; ButtonCancel.IsEnabled = false; }); try { switch (provider) { case MetadataProvider.Wiki: var wiki = new Wikipedia(); var page = wiki.GetPage(id); MetadataData = wiki.ParseGamePage(page, searchTerm); break; case MetadataProvider.IGDB: var igdb = new IGDB(); MetadataData = igdb.GetParsedGame(UInt64.Parse(id)); break; } } catch (Exception exc) { #if DEBUG logger.Error(exc, "Failed to download metadata from meta page."); #else logger.Warn(exc, "Failed to download metadata from meta page."); #endif Dispatcher.Invoke(() => { PlayniteMessageBox.Show("Didn't found any relevant information about game \"" + searchTerm + "\" on specified page."); }); TextDownloading.Dispatcher.Invoke(() => { ListSearch.Visibility = Visibility.Visible; TextDownloading.Visibility = Visibility.Hidden; ButtonOK.IsEnabled = true; ButtonCancel.IsEnabled = true; }); return; } Dispatcher.Invoke(() => { DialogResult = true; Close(); }); }); }
public void WikiContainer1() { Wikipedia wiki1 = new Wikipedia(driver); wiki1.goToSite(); wiki1.makeAllImagesScreen(); }
public void SendCmd(string arg, bool user = false) { if (user) { log.Add(arg); } List <string> args = arg.Split(' ').ToList(); string command = args[0]; string GetArgs(int index, int to = -1) { string data = ""; if (to == -1) { to = 999999999; } for (int i = 0; i < args.Count; i++) { if (i >= index && i <= to) { data += args[i] + " "; } } return(data.TrimEnd()); } if (arg.Split(' ')[0] == "echocl") { string color = arg.Split(' ')[1]; Add(GetArgs(2), Color.FromName(color)); return; } if (arg.Split(' ')[0] == "echoclcode") { try { int R = Convert.ToInt32(arg.Split(' ')[1]); int G = Convert.ToInt32(arg.Split(' ')[2]); int B = Convert.ToInt32(arg.Split(' ')[3]); Add(GetArgs(4), Color.FromArgb(R, G, B)); } catch (Exception ex) { ResultsList.FromException(ex); } return; } if (arg.Split(' ')[0] == "echo") { Add(GetArgs(1)); return; } if (arg.Split(' ')[0] == "ln") { if (GetArgs(1) == password) { Add("Logged In!", Color.Lime); login = true; return; } if (GetArgs(1) == "logout") { Add("Logged Out!", Color.Red); login = false; return; } Add("Bad Password!", Color.Red); return; } Add(" - " + arg, Color.Yellow); if (arg.Split(' ')[0] == "cd") { bool inoe = false; try { var tmp = arg.Split(' ')[1]; if (tmp == " ") { inoe = true; } } catch { inoe = true; } if (inoe) { List <FluentFTP.FtpListItem> items = FTPHandle.GetItemsList("/ScreenShot"); Add("Items In Dir : Main : "); for (int i = 0; i < items.Count; i++) { Add(items[i].Name, Color.Violet); } } else { List <FluentFTP.FtpListItem> items = FTPHandle.GetItemsList("/ScreenShot/" + arg.Split(' ')[1]); Add("Items In Dir : " + arg.Split(' ')[1] + " : "); for (int i = 0; i < items.Count; i++) { Add(items[i].Name, Color.Violet); } } return; } if (arg.Split(' ')[0] == "wshmax") { if (login) { try { wikipediamax = Convert.ToInt32(arg.Split(' ')[1]); Add("Limit set to " + wikipediamax.ToString(), Color.Lime); } catch { return; } return; } } if (arg.Split(' ')[0] == "color") { try { if (arg.Split(' ')[1] == "1" || arg.Split(' ')[1] == "0") { if (arg.Split(' ')[1] == "1") { color = true; } if (arg.Split(' ')[1] == "0") { color = false; } Add("Color is " + color.ToString(), Color.Lime); } richTextBox1.Visible = color; richTextBox2.Visible = !color; richTextBox2.Text = richTextBox1.Text; richTextBox2.SelectAll(); richTextBox2.SelectionColor = Color.Gray; richTextBox2.DeselectAll(); } catch { return; } return; } if (arg.Split(' ')[0] == "wsearch" || arg.Split(' ')[0] == "wsh") { if (login) { string querry = GetArgs(1); try { Add("Searching : " + querry, Color.Aqua); List <Search> searches = new List <Search>(); Wikipedia wikipedia = new Wikipedia(WikipediaNet.Enums.Language.Polish); wikipedia.Limit = wikipediamax; QueryResult result = wikipedia.Search(querry); List <string> results = new List <string>(); foreach (Search s in result.Search) { searches.Add(s); results.Add(s.Snippet); } for (int i = 0; i < results.Count; i++) { results[i] = results[i].Replace("<span class=\"searchmatch\">", ""); results[i] = results[i].Replace("</span>", ""); } for (int i = 0; i < results.Count; i++) { Add(results[i], Color.Violet); } } catch (Exception ex) { Add(ex.ToString()); } return; } } if (arg.Split(' ')[0] == "clear" || arg.Split(' ')[0] == "cs") { richTextBox1.Text = ""; log.Clear(); return; } if (arg.Split(' ')[0] == "credentials") { if (args.Count > 1) { if (args[1] == "reset") { FTPHandle.credential.Password = FTPHandle.haslo; FTPHandle.credential.UserName = FTPHandle.login; FTPHandle.adres = FTPHandle.adresfactory; Add("Credentials changed to factory", Color.Violet); } if (args[1] == "ping") { try { FluentFTP.FtpClient f = new FluentFTP.FtpClient(FTPHandle.adres, FTPHandle.credential); f.Connect(); f.Disconnect(); Add("Credentials ping succes", Color.Lime); } catch (Exception ex) { ResultsList.FromException(ex); Add("To reset write : credentials reset", Color.Violet); } return; } if (args[1] == "changepass") { FTPHandle.credential.Password = GetArgs(2); Add("Password changed to : " + GetArgs(2), Color.Violet); } if (args[1] == "changelogin") { FTPHandle.credential.UserName = GetArgs(2); Add("Login changed to : " + GetArgs(2), Color.Violet); } if (args[1] == "changehost") { FTPHandle.adres = GetArgs(2); Add("Host changed to : " + GetArgs(2), Color.Violet); } } Add("Login Credentials", Color.Yellow); Add("Host : " + FTPHandle.adres, Color.Violet); Add("Login : "******"Password : "******""; for (int i = 0; i < FTPHandle.credential.Password.Length; i++) { passhide += "*"; } if (!login) { Add("Password : "******"Null Command", Color.Red); }
void Start() { camera = Camera.main; hideUi(); wiki = GetComponent <Wikipedia>(); }
public void ParseGamePage_MetadataParsingTest() { var wiki = new Wikipedia(); // Standard page var game = wiki.ParseGamePage(wiki.GetPage("Guild Wars 2")); ValidateGameDate(game); ValidateBoxArt(game); // Without title in info box game = wiki.ParseGamePage(wiki.GetPage("Kingpin: Life of Crime")); ValidateGameDate(game); ValidateBoxArt(game); // Multiple release dates game = wiki.ParseGamePage(wiki.GetPage("Command & Conquer: Red Alert")); ValidateGameDate(game); ValidateBoxArt(game); // Multiple developers game = wiki.ParseGamePage(wiki.GetPage("Counter-Strike: Global Offensive")); ValidateGameDate(game); ValidateBoxArt(game); // Different page laytout game = wiki.ParseGamePage(wiki.GetPage("Quake III Arena")); ValidateGameDate(game); ValidateBoxArt(game); // Multiple property tables game = wiki.ParseGamePage(wiki.GetPage("Lotus_(series)"), "Lotus Turbo Challenge 2"); ValidateGameDate(game); ValidateBoxArt(game); game = wiki.ParseGamePage(wiki.GetPage("TrackMania"), "TrackMania United"); ValidateGameDate(game); ValidateBoxArt(game); // No image game = wiki.ParseGamePage(wiki.GetPage("State of War (video game)")); ValidateGameDate(game); // Different formats game = wiki.ParseGamePage(wiki.GetPage("Dungeon Siege")); ValidateGameDate(game); game = wiki.ParseGamePage(wiki.GetPage("MotoGP 3: Ultimate Racing Technology")); ValidateGameDate(game); game = wiki.ParseGamePage(wiki.GetPage("Quake 4")); ValidateGameDate(game); game = wiki.ParseGamePage(wiki.GetPage("DEFCON (video game)")); ValidateGameDate(game); game = wiki.ParseGamePage(wiki.GetPage("Kid Chaos (video game)")); ValidateGameDate(game); game = wiki.ParseGamePage(wiki.GetPage("StarCraft II: Wings of Liberty")); ValidateGameDate(game); game = wiki.ParseGamePage(wiki.GetPage("V-Rally")); ValidateGameDate(game); }
public static string Search(List <string> args) { Wikipedia w = new Wikipedia(WikipediaNet.Enums.Language.Polish); string q = Program.GetArgs(args, 1, -1); var rs = w.Search(q); int rstof = rs.Search.Count; if (rs.Search.Count > max) { rstof = max; } if (max == -1) { rstof = rs.Search.Count; } List <string> results = new List <string>(); for (int i = 0; i < rstof; i++) { string raw = rs.Search[i].Snippet; string f = raw.Replace("<span class=\"searchmatch\">", ""); f = f.Replace("</span>", ""); f = Program.MaskString(f, mask); if (mode == 0) { foreach (var item in CLCODE.codes) { f = f.Replace("&" + item, @"\&" + item); } results.Add("&d" + f); } if (mode != 0) { results.Add(f); } } if (mode == 0) { Program.WriteTxt("&e&4=&a-&4=&a-&4=&a-&4=&a-&4=&a-&4=&aWS RESULTS&4=&a-&4=&a-&4=&a-&4=&a-&4=&a-&4=&a-&4="); Program.WriteTxt(Program.GetArgs(results, 0, -1)); Program.WriteTxt("&4=&a-&4=&a-&4=&a-&4=&a-&4=&a-&4=&a-&4=&a-&4=&a-&4=&a-&4=&a-&4=&a-&4=&a-&4=&a-&4=&a-&4=&a-&4=&a-&4="); } if (mode == 1) { Clipboard.SetText(Program.GetArgs(results, 0, -1)); } if (mode == 2) { MessageBox.Show(Program.GetArgs(results, 0, -1), "Results"); } if (mode == 3) { for (int i = 0; i < results.Count; i++) { MessageBox.Show(results[i], $"Result {i + 1}/{results.Count}"); } } return(""); }
/// <summary> /// /// </summary> /// <param name="query"></param> /// <returns></returns> private Object GetSource(String query) { try { if (String.IsNullOrEmpty(query)) return null; Wikipedia wiki = new Wikipedia(new WikiQueryEngine()); SearchSuggestion suggestion = wiki.SearchArticles(query, 10); WikiControl omukControl = new WikiControl(); return suggestion; } catch { } return null; }
//txt/json export noch implementieren static void Main(string[] args) { //inputpath default: enwiki-latest-pages-articles.xml string inputPath = "enwiki-latest-pages-articles.xml"; //outputpath default: enwiki-latest-pages-articles.txt string outputPath = ""; //format default: text string format = "text"; if ((args.Length == 0) && !File.Exists(inputPath)) { Console.WriteLine("Download wikipedia dump files at: http://dumps.wikimedia.org/enwiki/latest/ https://dumps.wikimedia.org/enwiki/latest/enwiki-latest-pages-articles.xml.bz2"); Console.WriteLine(""); Console.WriteLine("Commandline Parameter missing"); Console.WriteLine("inputpath={path of wikipedia dump} outputpath={path of export file} format=text|json"); Console.ReadKey(); return; } foreach (string s in args) { string[] parameter = s.Split("="); if (parameter.Length > 1) { switch (parameter[0]) { case "inputpath": if (File.Exists(parameter[1])) { inputPath = Path.GetFullPath(parameter[1]); Console.WriteLine("inputpath=" + inputPath); } else { Console.WriteLine("Invalid value: " + s); } break; case "outputpath": if (Directory.Exists(parameter[1])) { outputPath = Path.GetFullPath(parameter[1]); Console.WriteLine("outputpath=" + outputPath); } else { Console.WriteLine("Invalid value: " + s); } break; case "format": //text or json format = parameter[1].ToLower(); if ((format == "text") || (format == "json")) { Console.WriteLine("format=" + format); } else { Console.WriteLine("Invalid value: " + s); } break; default: Console.WriteLine("Invalid parameter: " + s); break; } } } if (!String.IsNullOrEmpty(inputPath) && String.IsNullOrEmpty(outputPath)) { if (format == "text") { outputPath = Path.Combine(Path.GetDirectoryName(inputPath), Path.GetFileNameWithoutExtension(inputPath) + ".txt"); } else { outputPath = Path.Combine(Path.GetDirectoryName(inputPath), Path.GetFileNameWithoutExtension(inputPath) + ".json"); } } string urlPrefix = Path.GetFileName(inputPath).Substring(0, 1); //en Wikipedia wikipedia = new Wikipedia(); wikipedia.ReadWikipedia(( inputPath: inputPath, outputPath: outputPath, format: format, urlPrefix: urlPrefix) ); }