I'm trying to import this table from a wikipedia page containing the list of lunar missions into a Mathematica as an Association. Here, I'm trying to use the new WikipediaData function, but it doesn't seem to work.

WikipediaData["PageID" -> "656253283", "ArticleWikicode"]

• When I use your code, it doesn't work but WikipediaData["List of missions to the Moon", "ArticleWikicode"] works fine. – Mahdi May 6 '15 at 17:15
• Oh PageID is wrong, the correct one is 38293476. – Mahdi May 6 '15 at 17:17
• You can alwars just use Import : Import["http://en.wikipedia.org/wiki/List_of_missions_to_the_Moon", {"HTML", "Source"}] . ( WikipediaData doesn't work for me either by the way ) – george2079 May 6 '15 at 17:45
• This package could be used. The third example in that post is actually a table on Wikipedia. – C. E. May 7 '15 at 0:22
• The function you are using is not going to work because that's not the PageID of the article you are trying to import. The correct one is 38293476, so, WikipediaData["PageID" -> "38293476", "ArticleWikicode"] works fine. But as Mahdi said, you can also use the actual title as in WikipediaData["List of missions to the Moon", "ArticleWikicode"] – xtian777x Aug 27 '15 at 3:57

As george2079 said, you can use Import:

text = Import["https://en.wikipedia.org/wiki/List_of_missions_to_the_Moon", "Data"];


and then naively because table has 7 columns:

table = Cases[text, {_, _, _,_, _, _, _}, ∞];


But you need to do some clean-up afterwards!

my stab at it..

 source = Import[
"http://en.wikipedia.org/wiki/List_of_missions_to_the_Moon",
{"HTML", "Source"}];
tstart = StringPosition[source,
"<table class=\"wikitable sortable\"" ][[1, 1]];
tend = Select[
StringPosition[source, "</table>"] , #[[1]] > tstart & ][[1, 2]];
tabledata =
ImportString[
StringTake[ source , {tstart, tend} ], {"html", "Data"}];
Grid@tabledata


If there are more elegant ways of parsing html I'd like to see..

By the way WikipediaData gives me these sorts of errors no matter what I try:

" ServiceObject::noget: The parameter Wikicode is not available for the service Wikipedia. >> "