The Full Wiki

More info on Pywikipediabot/Pywikipediabot basics/Getting one page

Pywikipediabot/Pywikipediabot basics/Getting one page: Wikis


Note: Many of our articles have direct quotes from sources you can cite, within the Wikipedia article! This article doesn't yet, but we're working on it! See more info or our list of citable articles.

Study guide

Up to date as of January 14, 2010

From Wikiversity

The software should know on which site you are trying to operate. Usually, this is your default language and family inside of your file:

mylang = 'en'
family = 'wikinews'

By defining object "site" (or whatever name you give to this object) the bot will start to use this site:

site = getSite()

Even when it is usual that you are working with only one site, it will be better to always define the used language and family:

language = "en"
family = "wikinews"
site = getSite(language,family)

Now, we have defined object "site" and we are ready to fetch our first page. To do so, we have to define object "page" (or whatever name you give to this object). Let's say that we want to get the source of Main Page:

pagename = "Main Page"
page = Page(site,pagename)
pagetext = page.get()

And if you invoke "print pagetext", you will get Main Page of English Wikinews:

{{Main page header}}

{|{|cellpadding="5" cellspacing="3" class="mainpagetable"
| style="border: 1px solid #FFFFFF; padding: .5em 1em 1em; color: #000000; background-color: #ffffff; width:60%; vertical-align: top;" rowspan="3" |
{{Lead article}}
<div class="MainPageLatestNews">
=== Latest news <span class="plainlinks" style="font-size:70%;text-align:right;">[ <span class="rss">RSS</span>]</span>===
{{Latest news}}</div>


Got something to say? Make a comment.
Your name
Your email address