-1

I am running the following, and I notice that after 500, it stops, I would like it to run again starting from the next index in order to carry on searching:

var a = 0; 
jQuery.getJSON("https://en.wikipedia.org/w/api.php?action=query&list=embeddedin&&eilimit=1000000&eititle=Template:Infobox&callback=?", {
    disablelimitreport: true,
    format: "json"
}, function(data) {
    jQuery.each(data.query.embeddedin, function(i, item) {
        myTitle = item.title;
        wikiText();
        console.log(a);
        a++
    });
});

Is there anyway that I can tell it to start again from the next index after it finishes the first 500?

jsFiddle

I see it is stated on their documentation so I wonder how I could be making the next set of 500 calls if ever without having to get the dump

Termininja
  • 6,620
  • 12
  • 48
  • 49
rob.m
  • 9,843
  • 19
  • 73
  • 162
  • You could run it in a loop, but why do you want to make multiple batches of 500 calls to wikipedia? What are you trying to achieve? – J. S. Jul 24 '17 at 01:09
  • @JoãoSoares find any page on wikipedia which has an infobox – rob.m Jul 24 '17 at 01:52
  • That's a hefty chunk of processing, why don't you just create a paging feature. Surely the api has an "article count". Divide that by 500, returning the "pages" - loop though pages, job done. – Tez Wingfield Jul 24 '17 at 14:57
  • @TezWingfield no man, how would you go though all articles with an infobox? then choose those ones with 2 specific proprierties and then save the title and those proprierties within the infobox into a json? Believe me I know exactly that it is hell of a lot of processing but it needs to be done. the other solution would be to download the dump, yet you would still go and do the same thing – rob.m Jul 24 '17 at 16:18
  • @rob.m to be honest I'm not familiar with the Wikipedia API, purely an idea that sprung to mind instantly, hence commenting rather than answering but never the less, good luck with it. – Tez Wingfield Jul 24 '17 at 16:22
  • @if you know of any better way to find all articles with Location and date and be able to save title + Location + Date of the specific event/content/ then i'd be pleased to hear that. – rob.m Jul 24 '17 at 16:22
  • @TezWingfield wikipedia api is a mess, i know about wikidata and wikimedia but then again, you can make calls but the whole documntation is all over the places, there is no consistency at all. Eventually i said, you know what? I build my own, knowing it will take days to finish the loop probably but I will eventually get what I need. Unfortunatly lots of things will be left out, like: When was DNA discovered and where? No way to ask that to wikipedia by date and location only by title and then you will finally discover it by reading the whole article :( – rob.m Jul 24 '17 at 16:25

1 Answers1

3

From your first request you have to take the value of eicontinue (in your case it is '0|2645') and then use it for the next request:

https://en.wikipedia.org/w/api.php?action=query&list=embeddedin&&eilimit=1000000&eititle=Template:Infobox&callback=?&eicontinue=0|2645

And just continue in loop until eicontinue is available.

Termininja
  • 6,620
  • 12
  • 48
  • 49
  • thanks, I will post my own answer as I did resolve it. basically I get the last id, then ask it to loop again starting from that id, using eicontinue, so pretty much what you said, i found the way last night – rob.m Jul 24 '17 at 16:19
  • actually i accept it, it's the same thing what I did anyway. Thanks – rob.m Jul 24 '17 at 16:26