How to get the Infobox data from Wikipedia?

后端 未结 8 1354
感动是毒
感动是毒 2020-11-28 10:47

If I have the url to a page, how would I obtain the Infobox information on the right using MediaWiki webservices?

8条回答
  •  一向
    一向 (楼主)
    2020-11-28 11:02

    Use the Mediawiki API through this Python library: https://github.com/siznax/wptools

    Usage:

    import wptools
    so = wptools.page('Stack Overflow').get_parse()
    infobox = so.data['infobox']
    print(infobox)
    

    Output:

    {'alexa': '{{Increase}} 34 ( {{as of|2019|12|15|lc|=|y}} )',
     'author': '[[Jeff Atwood]] and [[Joel Spolsky]]',
     'caption': 'Screenshot of Stack Overflow in February 2017',
     'commercial': 'Yes',
     'content_license': '[[Creative Commons license|CC-BY-SA]] 4.0',
     'current_status': 'Online',
     'language': 'English, Spanish, Russian, Portuguese, and Japanese',
     'launch_date': '{{start date and age|2008|9|15}}',
     'logo': 'Stack Overflow logo.svg',
     'name': 'Stack Overflow',
     'owner': '[[Stack Exchange]], Inc.',
     'programming_language': '[[C Sharp (programming language)|C#]]',
     'registration': 'Optional',
     'screenshot': 'File:Stack Overflow homepage, Feb 2017.png',
     'type': '[[Knowledge market]]',
     'url': '{{URL|https://stackoverflow.com}}'}
    

提交回复
热议问题