[Python] How to get backlinks in certain pages in wikipedia in python?

Discussão em 'Python' iniciado por Stack, Setembro 25, 2024.

  1. Stack

    Stack Membro Participativo

    I am using the following code to get the backlinks of a page in wikipedia.

    import pywikibot as pw
    backlinks_list = []

    for item_backlink in pw.Page(pw.Site('en', 'wikipedia'), wikipedia_name).backlinks():
    backlinks_list.append(item_backlink.title())


    However, when I set the wikipedia_name = "Cyproheptadine" in the code, I get the following error.

    pywikibot.exceptions.CircularRedirect: Page [[en:Dibenzocycloheptene]] is a circular redirect.
    CRITICAL: Exiting due to uncaught exception <class 'pywikibot.exceptions.CircularRedirect'>


    I am wondering why this happens and how to get backlinks of such pages?

    I am happy to provide more details if needed.

    Continue reading...

Compartilhe esta Página