0

I'm using this code to fetch the article, but it contain only snipets of text:

$.ajax({
  url: "https://en.wikipedia.org/w/api.php?",
  data: {
    action: 'query',
    list: 'search',
    srsearch: "Richard Stallman",
    format: 'json'
  },
  dataType: 'jsonp',
  success: function(data){
      var datatp = '';
      data.query.search.map(function(f) {
          datatp += '<h3>' + f.title + '</h3>';
          datatp += f.snippet;
        });
      resultDiv.html(datatp);
    }
});

I found this question: How to get Wikipedia content using Wikipedia's API? but it show how to fetch first paragraph of the article in wiki markup. How can I fetch full article as text? I can live with wiki content I can figure out how to remove it from the text. JSFIDDLE

Community
  • 1
  • 1
jcubic
  • 61,973
  • 54
  • 229
  • 402

1 Answers1

1

You take the answer from that question, and leave out the specific rvsection argument. For example,

https://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&titles=pizza

Paul-Jan
  • 16,746
  • 1
  • 63
  • 95
  • It's already left out, instead add the rvsection as parameter with value 0 ;) – seahorsepip Jan 10 '16 at 18:42
  • No, rvsection=0 retrieves the first section. That's why I explicitly left it out in the sample URL above. – Paul-Jan Jan 10 '16 at 18:44
  • rvsection=1 retrieves the first section and rvsection=0 doesn't as far I can see. – seahorsepip Jan 10 '16 at 18:46
  • 2
    I gave a sample link for a reason. If you *click it*, you'll see that you get the -full content- of the Wikipedia pizza article. Are you saying the link above does not work for you? – Paul-Jan Jan 10 '16 at 18:50
  • Hmm then why is his code not working? Maybe rvprop=content? Or he might need to do a separate query for each search result. – seahorsepip Jan 10 '16 at 18:57