如何从Wikipedia页面摘要中提取链接?

问题描述 投票:-1回答:1

我想从Wikipedia页面的摘要中提取链接,以便比较语言版本的差异。但是,我只发现了示例代码来提取文章中的所有链接(例如一个波纹管)。我如何才能仅从此部分中提取?

wikipedia.page("name of the page").links
python wikipedia-api
1个回答
0
投票

查看代码,

  @property
  def links(self):
    '''
    List of titles of Wikipedia page links on a page.
    .. note:: Only includes articles from namespace 0, meaning no Category, User talk, or other meta-Wikipedia pages.
    '''

    if not getattr(self, '_links', False):
      self._links = [
        link['title']
        for link in self.__continued_query({
          'prop': 'links',
          'plnamespace': 0,
          'pllimit': 'max'
        })
      ]

    return self._links

API,似乎应该更改plnamespace参数。

© www.soinside.com 2019 - 2024. All rights reserved.