wikipedia-api

How to use Wikipedia API to get the page view statistics of a particular page in wikipedia?

僤鯓⒐⒋嵵緔 提交于 2019-11-27 01:51:33
问题 The stats.grok.se tool provides the pageview statistics of a particular page in wikipedia. Is there a method to use the wikipedia api to get the same information? What does the page views counter property actually mean? 回答1: The Pageview API was released a few days ago: https://wikimedia.org/api/rest_v1/metrics/pageviews/per-article/{project}/{access}/{agent}/{article}/{granularity}/{start}/{end} https://wikimedia.org/api/rest_v1/?doc#/ https://wikitech.wikimedia.org/wiki/Analytics/AQS

Fetch excerpt from Wikipedia article?

亡梦爱人 提交于 2019-11-27 01:40:39
问题 I've been up and down the Wikipedia API, but I can't figure out if there's a nice way to fetch the excerpt of an article (usually the first paragraph). It would be nice to get the HTML formatting of that paragraph, too. The only way I currently see of getting something that resembles a snippet is by performing a fulltext search (example), but that's not really what I want (too short). Is there any other way to fetch the first paragraph of a Wikipedia article than barbarically parsing HTML

Does Wikipedia API support CORS or only JSONP available?

*爱你&永不变心* 提交于 2019-11-26 23:11:55
This question related to another question , which was asked year ago. Author asked how to make cros-origin request using JavaScript and Wikipedia API and one comment was: en.wikipedia.org doesn't seem to allow CORS and he was advised to use JSONP instead. I know I can use JSONP, but I prefer CORS if I can use it. I tried on jsfiddle var url = "https://en.wikipedia.org/w/api.php?action=query&titles=Main%20Page&prop=revisions&rvprop=content&format=json"; $.ajax({ url: url, data: 'query', dataType: 'json', type: 'POST', headers: { 'Api-User-Agent': 'Example/1.0' }, origin: 'https://jsfiddle.net/'

Is there a clean wikipedia API just for retrieve content summary?

爱⌒轻易说出口 提交于 2019-11-26 18:00:24
I need just to retrieve first paragraph of a Wikipedia page. Content must be html formated, ready to be displayed on my websites (so NO BBCODE, or WIKIPEDIA special CODE!) There's a way to get the entire "intro section" without any html parsing! Similar to AnthonyS's answer with an additional explaintext param, you can get the intro section text in plain text. Query Getting Stack Overflow's intro in plain text: https://en.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&exintro&explaintext&redirects=1&titles=Stack%20Overflow JSON Response (warnings stripped) { "query": { "pages":

How to get results from the Wikipedia API with PHP?

不羁岁月 提交于 2019-11-26 17:08:44
问题 I'm probably not supposed to use file_get_contents() What should I use? I'd like to keep it simple. Warning: file_get_contents(http://en.wikipedia.org/w/api.php?action=query&titles=Your_Highness&prop=revisions&rvprop=content&rvsection=0): failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden 回答1: The problem you are running into here is related to the MW API's User-Agent policy - you must supply a User-Agent header, and that header must supply some means of contacting you. You

Get Text Content from mediawiki page via API

早过忘川 提交于 2019-11-26 15:19:18
问题 I'm quite new to MediaWiki, and now I have a bit of a problem. I have the title of some Wiki page, and I want to get just the text of a said page using api.php , but all that I have found in the API is a way to obtain the Wiki content of the page (with wiki markup). I used this HTTP request... /api.php?action=query&prop=revisions&rvlimit=1&rvprop=content&format=xml&titles=test But I need only the textual content, without the Wiki markup. Is that possible with the MediaWiki API? 回答1: I don't

How to get Wikipedia content using Wikipedia's API?

寵の児 提交于 2019-11-26 15:10:05
问题 I want to get the first paragraph of a Wikipedia article. What is the API query to do so? 回答1: See this section on the MediaWiki docs 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

Accessing main picture of wikipedia page by API [closed]

不问归期 提交于 2019-11-26 11:51:03
问题 Is there any way I can access the thumbnail picture of any wikipedia page by using an API? I mean the image on the top right side in box. Is there any APIs for that? 回答1: http://en.wikipedia.org/w/api.php Look at prop=images . It returns an array of image filenames that are used in the parsed page. You then have the option of making another API call to find out the full image URL, e.g.: action=query&titles=Image:INSERT_EXAMPLE_FILE_NAME_HERE.jpg&prop=imageinfo&iiprop=url or to calculate the

No response from MediaWiki API using jQuery

China☆狼群 提交于 2019-11-26 11:03:19
问题 I\'ve tried to get some content from Wikipedia as JSON: $.getJSON(\"http://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&titles=\"+title+\"&format=json\", function(data) { doSomethingWith(data); }); But I got nothing in response. If I paste to the browser\'s adress bar, something like http://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&titles=jQuery&format=json I get the expected content. What\'s wrong? 回答1: You need to trigger JSONP behavior

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

空扰寡人 提交于 2019-11-26 10:07:08
问题 I\'m trying to find out if there\'s a wikipedia api (I Think it is related to the mediawiki?). If so, I would like to know how I would tell wikipedia to give me an article about the new york yankees for example. What would the REST url be for this example? All the docs on this subject seem fairly complicated. 回答1: 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