Editing DS4UX (Spring 2016)/Wikipedia API
From CommunityData
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
<div style="font-family:Rockwell,'Courier Bold',Courier,Georgia,'Times New Roman',Times,serif; min-width:10em;"> | |||
<div style="float:left; width:100%; margin-right:2%;"> | |||
{{Link/Graphic/Main/2 | |||
|highlight color= 27666b | |||
|color=460c40 | |||
|link= | |||
|image= | |||
|text-align=left | |||
|top font-size= 1.1em | |||
|top color=FFF | |||
|line color=FFF | |||
|top text=This page is a work in progress. | |||
|bottom font-size= 1em | |||
|bottom color= FFF | |||
|bottom text= | |||
|line= none | |||
}}</div></div> | |||
<div style="clear:both;"></div> | |||
[[File:Wikipedia.png|right|250px]] | [[File:Wikipedia.png|right|250px]] | ||
__NOTOC__ | |||
== Getting data from Wikipedia | == Getting data from the Wikipedia API == | ||
In this project, we will explore a few ways to gather data using the Wikipedia API. Once we've done that, we will extend this to code to create our own datasets of Wikipedia edits or other data that we might be able to use to ask and answer questions in future sessions. | In this project, we will explore a few ways to gather data using the Wikipedia API. Once we've done that, we will extend this to code to create our own datasets of Wikipedia edits or other data that we might be able to use to ask and answer questions in future sessions. | ||
Line 16: | Line 35: | ||
=== Download and test the Wikipedia project === | === Download and test the Wikipedia project === | ||
# Right click the following file, click "Save Target as..." or "Save link as...", and save it to your Desktop directory: FIXME | |||
# The ".zip" extension on the above file indicates that it is a compressed Zip archive. We need to "extract" its contents. | # The ".zip" extension on the above file indicates that it is a compressed Zip archive. We need to "extract" its contents. | ||
Line 23: | Line 42: | ||
python wikipedia1-1.py | python wikipedia1-1.py | ||
== What | == What is Wikipedia? == | ||
* As you probably already know, Wikipedia is a website that anyone can edit. | * As you probably already know, Wikipedia is a website that anyone can edit. | ||
Line 56: | Line 75: | ||
=== Editor metadata === | === Editor metadata === | ||
You can get metadata about a particular editor through the <code>usercontribs=</code> parameter. Here are some of the things you can get ([[Click here for the full list|mw:API:Revisions#Parameters]]): | |||
* | * https://www.mediawiki.org/wiki/API:Usercontribs | ||
* https://www.mediawiki.org/wiki/API:Users | |||
=== Page text and metadata === | === Page text and metadata === | ||
Line 66: | Line 86: | ||
* links: the links on a page: https://www.mediawiki.org/wiki/API:Links | * links: the links on a page: https://www.mediawiki.org/wiki/API:Links | ||
* categorymembers: all of the pages that are in a particular category: https://www.mediawiki.org/wiki/API:Categorymembers | * categorymembers: all of the pages that are in a particular category: https://www.mediawiki.org/wiki/API:Categorymembers | ||
== | == Example API queries == | ||
* looking at the images within a page (try this with another city by changing the value of <code>titles=</code>!): http://en.wikipedia.org/w/api.php?action=query&titles=Seattle&prop=images&imlimit=20&format=jsonfm | * looking at the images within a page (try this with another city by changing the value of <code>titles=</code>!): http://en.wikipedia.org/w/api.php?action=query&titles=Seattle&prop=images&imlimit=20&format=jsonfm | ||
Line 76: | Line 94: | ||
* get the content of the main page http://en.wikipedia.org/w/api.php?format=json&action=query&titles=Main%20Page&prop=revisions&rvprop=content | * get the content of the main page http://en.wikipedia.org/w/api.php?format=json&action=query&titles=Main%20Page&prop=revisions&rvprop=content | ||
== Resources == | === Resources === | ||
=== API === | ==== API ==== | ||
* [https://www.mediawiki.org/wiki/API:Main_page Main MediaWiki API Documentation] | * [https://www.mediawiki.org/wiki/API:Main_page Main MediaWiki API Documentation] | ||
* [https://en.wikipedia.org/w/api.php Autogenerated API Documentation] | * [https://en.wikipedia.org/w/api.php Autogenerated API Documentation] | ||
Line 85: | Line 102: | ||
* [[Sample API queries]] | * [[Sample API queries]] | ||
=== Research using Wikipedia data === | ==== Research using Wikipedia data ==== | ||
=== Websites that use the MediaWiki API === | ==== Websites that use the MediaWiki API ==== | ||
[[Category:DS4UX (Spring 2016)]] | [[Category:DS4UX (Spring 2016)]] |