Wikimedia API: How to get page contents - wikipedia-api

I am trying to get the content of the wikimedia pages like these ones:
https://meta.wikimedia.org/wiki/MediaWiki:Centralnotice-FR2015_translations-smallamount-error
https://meta.wikimedia.org/wiki/MediaWiki:FundraisingBanners/SmallPrint-2017
I am working on something related to translations and banners but I'm stuck in this step.
I've been testing several of the endpoints in this API https://www.mediawiki.org/w/api.php with not succeed.
Could you help me please?

These are what you want:
https://meta.wikimedia.org/w/api.php?action=query&prop=revisions&rvslots=*&rvprop=content&format=json&titles=MediaWiki:Centralnotice-FR2015_translations-smallamount-error
https://meta.wikimedia.org/w/api.php?action=query&prop=revisions&rvslots=*&rvprop=content&format=json&titles=MediaWiki:FundraisingBanners/SmallPrint-2017
Let me know if you're struggling to extract the content from those.

Related

Get wikitext from wikipedia API?

I'm looking at the API documentation here,
https://www.mediawiki.org/wiki/API:Query
Getting the wikitext for a page is mentioned in the beginning of the documentation,
The action=query module allows you to get information about a wiki and the data stored in it, such as the wikitext of a particular page, the links and categories of a set of pages, or the token you need to change wiki content.
but I cant seem to figure out what parameters to pass in the API request to return the wikitext for a given page. Anyone know how to do this?
I've tried parameters like,
{'action':'query', 'titles':'Anarchism', 'prop':'wikitext', 'format':'json'}
You must use this query .
https://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&format=json&titles=Anarchism&rvslots=main

How to get such header title and search input in Google search for website

How to get such header title and search input in Google search for website like below:
I am doing my website with core PHP (not any CMS like WordPress, Drupal etc.). So please help me to get such a result in Google.
This is called Sitelinks.
Check it out here: https://support.google.com/webmasters/answer/47334?hl=en
It's an Google automated process and you can't do much to control it. Although a google search on "how to get sitelinks" gives you plenty of results on how to get them, for example, here, or here.
Or perhaps you can purchase them under your AdWords advertisement.
As far as I know, it is much related to PHP. It's more on Search Engine Optimization (SEO).

Accessing full url of all page images Wikipedia API

I'm experimenting with the Wikipedia API and was trying to get the full urls for all images on a particular page, in this example Google's main page (http://en.wikipedia.org/wiki/Google).
I found the page id through the use of another API and then attempted to use this information in the following API to get the full urls of all images on that page:
http://en.wikipedia.org/w/api.php?action=query&pageids=1092923&generator=images&prop=imageinfo&iiprop=url|dimensions|mime&format=xml
I get some of the page images from this but cannot understand why I am not getting all - specifically the logo which is what I was most interested in. Apologies I am aware that there are similar questions which have been asked but I was not able to find one which would assist me here.
The API does not give you all results at once, it defaults to 10 results. You see in the beginning answer that you have a value for the parameter gimcontinue. If you use it like this you get more images: http://en.wikipedia.org/w/api.php?action=query&pageids=1092923&generator=images&prop=imageinfo&iiprop=url|dimensions|mime&format=xml&gimcontinue=1092923|Google_bike.jpg
Alternatively, you can ask for more images at once using gimlimit like this: http://en.wikipedia.org/w/api.php?action=query&pageids=1092923&generator=images&prop=imageinfo&iiprop=url|dimensions|mime&format=xml&gimlimit=500

Get all page ids linked to a given wikipedia page

I am trying to use the wikimedia public apis for accessing the english wikipedia database.
I would like to have a way to obtain all the page ids linked to a given page.
If I do like this:
http://en.wikipedia.org/w/api.php?action=query&titles=computer&format=xml
I am only able to obtain the page id of the 'computer' page.
I know I could parse for the 'href' tags inside that page and make n queries, but it is not very efficient.
Can I achieve this through apis alone?
It looks like you're looking for the backlinks module.
With that, you can do something like:
http://en.wikipedia.org/w/api.php?action=query&bltitle=computer&list=backlinks&format=xml
Also, the API uses paging, so you'll most likely need to add &bllimit=max to the query and then make follow-up requests to get the remaining pages.

Customize Google Custom Search

Does anyone know how to span the search result set over all of the links provided in google custom search . For Example, if I have provided sites like site 1,site 2....site n to search from ,then I want say top five results from all of these individual websites as JSON. Is there a way to achieve this.
I know this may be a little late but might be able to help someone out .
This will return 2 results via the REST API for GCSE.
https://www.googleapis.com/customsearch/v1?key=YOUR-KEY_HERE&cx=CX_HERE&fields=kind,items&filter=1&num=2&prettyPrint=true&q=querystring
its the num=2 part your looking for...