ashvagan
ashvagan

Reputation: 43

wikitools, wikipedia and python

Does anybody have experience in getting a wikipedia page using wikitools for python (and django)? I am trying to get the article but I get a few first lines and that's it. I need to fetch the whole article and I can't seem to figure it out. The documentation is not very helpful either. My code is:

wikiobj = wiki.Wiki("http://en.wikipedia.org/w/api.php?title=Some_Title&action=raw&maxlag=-1") 
wikipage = page.Page(wikiobj, url, section='content')
wikidata = wikipage.getWikiText(True).decode('utf-8', 'replace')

Any help will be appreciated.

Upvotes: 1

Views: 1083

Answers (1)

dragoon
dragoon

Reputation: 5743

I'm using wikitools im my project, not for getting text on the page, but I initialize wiki object in a different way:

wikiobj = wiki.Wiki("http://en.wikipedia.org/w/api.php")
wikipage = page.Page(wikiobj, title="Some_Title")

You don't need to supply any query to after api.php in the Wiki class.

Next, look at the definition of Page class:

__init__(self, site, title=False, check=True, followRedir=True, section=False, sectionnumber=False, pageid=False, namespace=False)

So you need to supply title to the constructor of the Page class (you supplied some unknown url param).

Upvotes: 1

Related Questions