2011-12-08 13 views
2

Wikipediafirst paragraph記事を取得したいと思います。だから私はwikitoolsを使用しています。Pythonを使用してウィキペディアの要約を取得する

from wikitools import wiki 
from wikitools import api 
from wikitools import page 

wikiobj = wiki.Wiki("http://en.wikipedia.org/w/api.php") 
wikipage = page.Page(wikiobj, title="Office_Space") 
wikidata = wikipage.getWikiText(True) 
print wikidata 

ここはresult of wikitoolsです。この結果、非常に多くのタグがあります。私はこれをすべて望んでいない。

articleの次の部分のみ必要です。 (ウィキペディアからペーストをコピーする)。出来ますか?ありがとう。あるいは、他の選択肢がありますか?どうもありがとうございます。

Office Space is a 1999 American comedy film satirizing work life in a typical 1990s software company. Written and directed by Mike Judge, it focuses on a handful of individuals fed up with their jobs portrayed by Ron Livingston, Jennifer Aniston, Gary Cole, David Herman, Ajay Naidu, and Diedrich Bader. 
    The film's sympathetic depiction of ordinary IT workers garnered a cult following within that field, but also addresses themes familiar to white collar employees in general. 
    Shot in Las Colinas and Austin, Texas, Office Space is based on Judge's Milton cartoon series. It was his first foray into live action film and second full length motion picture release. 

答えて

0

それはあなたがあなたが欲しいだけのビットを抽出することができ、そこからPythonのデータ構造に返すwikitoolsすべてを、置くことができますよう(this article on how to scrape and parse Wikipediaで参照)wikipedia_utilsでテンプレートパーサが見えます。

編集:this SO answerに記載されているように、この目的に役立つPythonライブラリmwlibがあります。

関連する問題