Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get categories from wiki page #10

Open
arieljannai opened this issue Mar 12, 2013 · 3 comments
Open

get categories from wiki page #10

arieljannai opened this issue Mar 12, 2013 · 3 comments
Assignees

Comments

@arieljannai
Copy link
Collaborator

getting all the categories assigned to a given wiki page

@ghost ghost assigned arieljannai Mar 12, 2013
@arieljannai arieljannai reopened this Mar 12, 2013
@arieljannai
Copy link
Collaborator Author

To get all the categories of a wiki page we will invoke this:
http://en.wikipedia.org/w/api.php?format=json&action=query&titles=Java&prop=categories&clshow=!hidden

  • format=json OR xml (maybe more)
  • action=query (there is a lot more)
  • titles=Our wiki page
  • prop=categories (if more then one, use | (pipe line) to seperate them)
  • clshow=!hidden (or nothing, or hidden) - to get only the visible categories. Usualy, the hidden categories are used to wiki admins and bots.

The result is something like this:

{"query":{"pages":{"69336":{"pageid":69336,"ns":0,"title":"Java","categories":[{"ns":14,"title":"Category:All articles with unsourced statements"},{"ns":14,"title":"Category:Articles containing Indonesian language text"},{"ns":14,"title":"Category:Articles with unsourced statements from June 2009"},{"ns":14,"title":"Category:Greater Sunda Islands"},{"ns":14,"title":"Category:Java"}]}}}}

As we can see, the page is tagged to couple of categories, like:

  • Greater Sunda Islands
  • Java

@arieljannai
Copy link
Collaborator Author

more information about wiki api at:
http://en.wikipedia.org/w/api.php

@arieljannai
Copy link
Collaborator Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant