封裝了Wikipedia(維基百科網站) API的Python庫:Wikipedia
Wikipedia是一個Python庫,它封裝了Wikipedia(維基百科網站) API,讓獲取和解析Wikipedia網站的數據變得非常簡單,功能包括搜索Wikipedia、獲取文章摘要、獲取頁面的鏈接或者圖像數據等等。
>>> import wikipedia >>> print wikipedia.summary("Wikipedia")Wikipedia (/?w?k??pi?di?/ or /?w?ki?pi?di?/ WIK-i-PEE-dee-?) is a collaboratively edited, multilingual, free Internet encyclopedia supported by the non-profit Wikimedia Foundation...
>>> wikipedia.search("Barack")
[u'Barak (given name)', u'Barack Obama', u'Barack (brandy)', u'Presidency of Barack Obama', u'Family of Barack Obama', u'First inauguration of Barack Obama', u'Barack Obama presidential campaign, 2008', u'Barack Obama, Sr.', u'Barack Obama citizenship conspiracy theories', u'Presidential transition of Barack Obama']
>>> ny = wikipedia.page("New York") >>> ny.title
u'New York'
>>> ny.url
u'
>>> ny.content
u'New York is a state in the Northeastern region of the United States. New York is the 27th-most exten'...
>>> ny.links[0]
u'1790 United States Census'
>>> wikipedia.set_lang("fr") >>> wikipedia.summary("非死book", sentences=1)
非死book est un service de réseautage social en ligne sur Internet permettant d'y publier des informations (photographies, liens, textes, etc.) en contr?lant leur visibilité par différentes catégories de personnes.</pre>
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!