python 解析维基百科字符串中的文章链接

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 解析维基百科字符串中的文章链接相关的知识,希望对你有一定的参考价值。

import mwlib.parser.nodes
import mwlib.uparser 
import codecs


with codecs.open('us.dat', 'rb', encoding='utf-8') as fp: 
    text = fp.read()
    article = mwlib.uparser.parseString(title='us', raw=text) 
    nodes = article.find(mwlib.parser.nodes.ArticleLink) 
    for n in nodes:
        print n

以上是关于python 解析维基百科字符串中的文章链接的主要内容,如果未能解决你的问题,请参考以下文章