php – 如何使用MediaWiki解析器从wikitext获取HTML

我正在尝试使用Wikipedia的MediaWiki解析器来解析维基百科标记文本到
HTML.

我在这里阅读了手册 –
https://www.mediawiki.org/wiki/Manual:Parser.php

但是,因为我是PHP的新手,所以我无法编写测试脚本,

这是我想要解析并转换为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.

最佳答案 你甚至不必使用PHP.您可以使用Wikipedia的API(或您自己的MediaWiki安装上的API).有关更多信息,请参见
Parsing wikitext.

点赞