Does Wikipedia API support CORS or only JSONP available?

To make JavaScript Fetch/XHR requests to Wikipedia, add origin=* to the URL query params. So the base of the URL in the question should be like this: https://en.wikipedia.org/w/api.php?origin=*&action=query… See the CORS-related docs for the Wikipedia backend: For anonymous requests, origin query string parameter can be set to * which will allow requests from anywhere. 2016-05-09 … Read more

No response from MediaWiki API using jQuery

You need to trigger JSONP behavior with $.getJSON() by adding &callback=? on the querystring, like this: $.getJSON(“http://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&titles=”+title+”&format=json&callback=?”, function(data) { doSomethingWith(data); }); You can test it here. Without using JSONP you’re hitting the same-origin policy which is blocking the XmlHttpRequest from getting any data back.

How can I get Wikipedia content using Wikipedia’s API?

See this section in the MediaWiki API documentation, specifically involving getting the contents of the page. use the sandbox to test the API call. These are the key parameters. prop=revisions&rvprop=content&rvsection=0 rvsection = 0 specifies to only return the lead section. See this example. http://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&rvsection=0&titles=pizza To get the HTML, you can use similarly use action=parse http://en.wikipedia.org/w/api.php?action=parse&section=0&prop=text&page=pizza … Read more

How to use wikipedia api if it exists? [closed]

You really really need to spend some time reading the documentation, as this took me a moment to look and click on the link to fix it. :/ but out of sympathy i’ll provide you a link that maybe you can learn to use. http://en.wikipedia.org/w/api.php?action=query&prop=revisions&titles=New_York_Yankees&rvprop=timestamp|user|comment|content That’s the variabled you will be looking to get. Your … Read more

Is there a Wikipedia API just for retrieve the content summary?

There’s a way to get the entire “introduction section” without any HTML parsing! Similar to AnthonyS’s answer with an additional explaintext parameter, you can get the introduction section text in plain text. Query Getting Stack Overflow’s introduction in plain text: Using the page title: https://en.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&exintro&explaintext&redirects=1&titles=Stack%20Overflow Or use pageids: https://en.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&exintro&explaintext&redirects=1&pageids=21721040 JSON Response (warnings stripped) { “query”: … Read more

How to extract information from a Wikipedia infobox?

The wrong way: trying to parse HTML Use (cURL/jQuery/file_get_contents/requests/wget/more jQuery) to fetch the HTML article code of the article, then use a DOM parser to extract table.infobox tr[3] td / use a regex. This is actually a really bad idea most of the time. Wikipedia’s HTML code is not particularly parsing-friendly (especially infoboxes which are … Read more