2013-08-22 27 views
2

我正在嘗試使用維基百科的MediaWiki解析器來將Wikipedia標記文本解析爲HTML。 我通過手動去這裏 - https://www.mediawiki.org/wiki/Manual:Parser.php 然而,因爲我完全新的PHP,我不能寫一個測試腳本,如何使用MediaWiki解析器從wikitext獲取HTML

這裏是我想解析和轉換爲HTML樣本輸入:

Shakespeare's sonnets 
==Characters== 
When analysed as characters, the subjects of the sonnets are usually referred 
to as the Fair Youth, the Rival Poet, and the Dark Lady. The speaker expresses 
admiration for the Fair Youth's beauty, and later has an affair with the Dark 
Lady. It is not known whether the poems and their characters are fiction or 
autobiographical; scholars who find the sonnets to be autobiographical, notably 
[[A. L. Rowse]], have attempted to identify the characters with historical 
individuals. 
+0

我使用這個項目來解析 https://code.google.com/p/gwtwiki/ 這個項目給了我HTML輸出,但保留超鏈接和一些標籤,我想刪除,所以我將不得不寫一個scrubber 但是mediawiki解析器的文檔聲明它定義了函數來獲取我需要的,所以我希望使用它..而且它的官方解析器爲Wikipedia –

回答

2

你甚至不需要使用PHP。您可以使用Wikipedia的API(或在您自己的MediaWiki安裝中使用API​​)。有關更多信息,請參閱Parsing wikitext

+0

將檢查它,謝謝! –

0

您可以使用JWPL http://code.google.com/p/jwpl/,它將與維基的本地副本一起使用。 加載轉儲,轉換爲數據主機,導入到數據庫中,按照您的要求進行操作。

+0

歡迎來到SO,鏈接只有答案不是SO中的最佳實踐,因爲鏈接被刪除/刪除或刪除時答案已過時。 –