Suppose, I have a list of sightseeings in one language and want to enrich this list with some data from Wikipedia.
So, I have the following data -- city is Munich and it has the following attractions:
I need to perform the following:
I tried Linq-to-Wiki from NuGet Repository, but I can't get this scenario to run... Here is my code that justly times out:
var enwiki = new Wiki("LinqToWiki.Samples", "en.wikipedia.org", "/w/api.php");
var result = enwiki.Query.allpages()
.Pages
.Select (
page =>
new
{
Title = page.info.title,
Text = page.revisions()
.Where( r => r.section == "0")
.Select( r => r.value)
);
If you know the titles of the articles in question, you can do something like:
var titles = wiki.CreateTitlesSource(
"Munich Frauenkirche", "Marienplatz", "Karlsplatz (Stachus)");
var pages =
titles.Select(
page => new
{
Title = page.info.title,
Text = page.revisions()
.Where(r => r.section == "0" && r.parse)
.Select(r => r.value)
.FirstOrDefault(),
LangLinks = page.langlinks().ToEnumerable()
}).ToEnumerable();
LangLinks will contain titles of the article in different languages.
Text will contain HTML of the first section. If you think wikitext would be better, you could get that instead by removing && r.parse.
There is also extracts module that seems to support getting actual plaintext, but that module is currently not supported by LinqToWiki.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With