kunwar nitesh
kunwar nitesh

Reputation: 83

Fetch text from Wikipedia randomly

Can we fetch text from Wikipedia randomly? I do not care about the content of the text, the whole I need is to fetch random text whenever I query for the same.

http://en.wikipedia.org/w/api.php?format=json&action=query&titles=Virat_Kohli&prop=revisions&rvprop=content

The above API gives the result corresponding to the given title (Virat_Kohli), but I do not want to give any title to the API.

Upvotes: 0

Views: 208

Answers (1)

Ainali
Ainali

Reputation: 1641

Yes, use a generator with random. Just ommit the title and append this to your query &generator=random&grnnamespace=0&grnlimit=1

Example: http://en.wikipedia.org/w/api.php?action=query&prop=revisions&format=json&rvprop=content&generator=random&grnnamespace=0&grnlimit=1

Upvotes: 3

Related Questions