pywikibot | Python library that interfaces with the MediaWiki API | REST library

 by   wikimedia Python Version: 9.2.0 License: MIT

kandi X-RAY | pywikibot Summary

kandi X-RAY | pywikibot Summary

pywikibot is a Python library typically used in Web Services, REST applications. pywikibot has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has high support. You can install using 'pip install pywikibot' or download it from GitHub, PyPI.

A Python library that interfaces with the MediaWiki API. This is a mirror from gerrit.wikimedia.org. Do not submit any patches here. See https://www.mediawiki.org/wiki/Developer_account for contributing.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              pywikibot has a highly active ecosystem.
              It has 552 star(s) with 189 fork(s). There are 49 watchers for this library.
              There were 2 major release(s) in the last 6 months.
              pywikibot has no issues reported. There are no pull requests.
              It has a positive sentiment in the developer community.
              The latest version of pywikibot is 9.2.0

            kandi-Quality Quality

              pywikibot has 0 bugs and 0 code smells.

            kandi-Security Security

              pywikibot has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              pywikibot code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              pywikibot is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              pywikibot releases are not available. You will need to build from source code and install.
              Deployable package is available in PyPI.
              Build file is available. You can build the component from source.
              It has 82068 lines of code, 7676 functions and 295 files.
              It has medium code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed pywikibot and discovered the below as its top functions. This is intended to give you an instant insight into pywikibot implemented functionality, and help decide if they suit your requirements.
            • Implements the upload method .
            • Find claims .
            • Process disambiguation only .
            • Replace links in new pages .
            • Edit a page .
            • Move the text to a specific category .
            • Remove templates from the page .
            • Check if image has duplicates .
            • Submit the request .
            • Clean up links in text .
            Get all kandi verified functions for this library.

            pywikibot Key Features

            No Key Features are available at this moment for pywikibot.

            pywikibot Examples and Code Snippets

            No Code Snippets are available at this moment for pywikibot.

            Community Discussions

            QUESTION

            How to add space in python's search/find string?
            Asked 2022-Apr-04 at 04:51

            I have been running a pywikibot on Marathi wikipedia since almost a month now. The only task of this bot is find and replace. You can find overall details of pywikibot at: pywikibot. You can find the details of that particular find and replace operation at replace.py and fixes.py and even further examples of fixes here.

            The following is a part of my source code. When running the bot on Marathi wikipedia, I am facing a difficulty because of the Marathi language's script. All of the replacements are going fine, but one is not. For example, I will use English words instead of Marathi.

            The first part ("fix") of following code searches for "{{PAGENAME}}", and replaces it with "{{subst:PAGENAME}}". The msg parameter is the edit summary.

            The second fix of the code "man", finds "man" and replaces it with "gent". But the problem is, it is also replacing "human" to "hugent", "craftsmanship" to "craftsgentship" and so on.

            ...

            ANSWER

            Answered 2022-Apr-04 at 04:51

            You want occurrances of 'man', but only by itself - in other words, only if it's not preceded or followed by other letters or symbols that would be part of a word.

            I don't know if Marathi contains symbols like '-' that could be part of a word, for example 'He was a real man-child', in which case you may or may not want to replace it.

            In English, since you're using regex, you can do this:

            Source https://stackoverflow.com/questions/71731964

            QUESTION

            pywikibot.exceptions.TimeoutError - how to modify the default
            Asked 2021-Dec-18 at 17:27

            in my github actions unit test i am running some pywikibot code (pywikibot 6.6.3) that some times fails due to the site not being responsive or a misconfiguration. The log report used to show the error messages after a few minutes.

            Now the code runs some 2 hours and more with hint such as:

            ...

            ANSWER

            Answered 2021-Dec-18 at 17:27

            the style of setting the variables is:

            Source https://stackoverflow.com/questions/70405154

            QUESTION

            Get links from summary section of wikipedia page
            Asked 2021-Jun-08 at 03:47

            I am trying to extract links from the summary section of a wikipedia page. I tried the below methods :

            This url extracts all the links of the Deep learning page: https://en.wikipedia.org/w/api.php?action=query&prop=links&titles=Deep%20learning

            And for extracting links associated to any section I can filter based on the section id - for e.g.,

            for the Definition section of same page I can use this url : https://en.wikipedia.org/w/api.php?action=parse&prop=links&page=Deep%20learning&section=1

            for the Overview section of same page I can use this url : https://en.wikipedia.org/w/api.php?action=parse&prop=links&page=Deep%20learning&section=2

            But I am unable to figure out how to extract only the links from summary section

            I even tried using pywikibot to extract linkedpages and adjusting plnamespace variable but couldn't get links only for summary section.

            ...

            ANSWER

            Answered 2021-Jun-04 at 13:32

            You need to use https://en.wikipedia.org/w/api.php?action=parse&prop=links&page=Deep%20learning&section=0

            Note that this also includes links in the {{machine learning bar}} and {{Artificial intelligence|Approaches}} templates however (to the right of the screen).

            Source https://stackoverflow.com/questions/67837003

            QUESTION

            How do I use pywikibot.Page(site, title).text when the title has an unescaped apostrophe (')?
            Asked 2021-Feb-12 at 17:17

            I have a list of strings called cities, where each string is a city name that is also the title of a wikipedia page. For each city, I'm getting the wikipedia page and then looking at the text content of it:

            ...

            ANSWER

            Answered 2021-Feb-11 at 06:29

            re.sub("'", "\'", city) does not do anything:

            Source https://stackoverflow.com/questions/66149239

            QUESTION

            How do I get a list of all of the quotes for a particular person from the mediawiki API?
            Asked 2020-Nov-02 at 17:10

            I am trying to get a list of all of Kurt Cobain's quotes from the mediawiki api. I have:

            https://en.wikiquote.org/w/api.php?format=json&action=query&srsearch=Kurt+Cobain&list=search

            BUT, it doesn't seem to give me any of his quotes as shown here...nor does it provide a good format to be able to parse easily.

            How do I get a list of all of his quotes using the API? If possible would also like to include the source - e.g. From an interview on MTV with Zeca Camargo, 1993-01-21, Rio de Janeiro, Brazil

            Would prefer the API directly but an answer with pywikibot is also good.

            ...

            ANSWER

            Answered 2020-Nov-02 at 17:10

            There is no structured data like templates to get the quotes. All you can do is to retrieve quotes via regex from plain wikitext, something like:

            Source https://stackoverflow.com/questions/63422089

            QUESTION

            How to disable "Sleeping for N seconds" on PyWikiBot
            Asked 2020-Mar-27 at 11:47

            At Pywikibot's Mediawiki Talk page this question has been asked some 2 years ago already.

            The answers there were along the lines "you shouldn't" and maxthrottle isn't the right parameter for that.

            For intranet usecases the throttle is mostly counterproductive. Especially when testing the automation the throttle kicks in no matter how low the number of API accesses is. So I'd rather switch if off or set it to a reasonable time of a few millisecs instead of the default 10 seconds.

            How can the throttle be set to a different time?

            ...

            ANSWER

            Answered 2020-Mar-27 at 11:47

            QUESTION

            How to create and or edit a page with pyWikiBot
            Asked 2020-Mar-27 at 10:06

            The MediaWiki API has an edit function which is available within pywikibot. According to https://doc.wikimedia.org/pywikibot/master/api_ref/pywikibot.site.html

            the function is called with a page parameter:

            ...

            ANSWER

            Answered 2020-Mar-27 at 10:05

            The following code works:

            Source https://stackoverflow.com/questions/60883319

            QUESTION

            How to get backlinks in certain pages in wikipedia in python?
            Asked 2020-Mar-24 at 16:15

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

            ...

            ANSWER

            Answered 2020-Mar-24 at 16:15

            By default, .backlinks() includes backlinks of redirected pages. While this is sometimes a desired feature, it causes the error in your case. "Dibenzocycloheptene" is a backlink of "Cyproheptadine", but "Dibenzocycloheptene" is also a redirect to "Dibenzosuberane" which is again a redirect to "Dibenzocycloheptene". This is a circle and thus pywikibot throws an error.

            You can solve this problem by setting .backlinks(follow_redirects=False). Then backlinks of redirects will not be included in your list.

            As circular redirects are quite rare, you could also solve this problem at the source: go to Wikipedia and cut the circle by removing the redirect link on "Dibenzocycloheptene".

            Source https://stackoverflow.com/questions/60823097

            QUESTION

            How to parse Wikipedia talk page content by contributor?
            Asked 2020-Mar-09 at 10:34

            I am looking to parse the Wikipedia talk page (e.g., https://en.wikipedia.org/wiki/Talk:Elon_Musk). I would like to loop through texts by contributors/editors. Not sure how do I do it. For now, I have the following code:

            ...

            ANSWER

            Answered 2020-Mar-09 at 10:34

            I don't know about pywikibot, but you can do this via the normal API. This will fetch the revisions: https://en.wikipedia.org/w/api.php?action=query&prop=revisions&titles=Talk:Elon%20Musk&rvlimit=500&rvprop=timestamp|user|comment|ids

            Then you can pass the revision ids to get the change in each edit: e.g. https://en.wikipedia.org/w/api.php?action=compare&fromrev=944235185&torev=944237256

            Source https://stackoverflow.com/questions/60532122

            QUESTION

            How can I get details about reverted edits of a wiki page?
            Asked 2020-Mar-02 at 05:54

            I am using pywikibot in python to get all revisions of a Wikipedia page.

            import pywikibot as pw wikiPage='Narthaki' page = pw.Page(pw.Site('en'), wikiPage) revs = page.revisions(content=True)

            How do I know which of the revisions were reverts? I see from https://xtools.wmflabs.org/articleinfo/en.wikipedia.org/Narthaki that the page has one revert edit. Not sure how to get more information about this from the revision object.

            Request your help. Many thanks!

            ...

            ANSWER

            Answered 2020-Mar-02 at 05:20

            You can compare text of revision directly, or look for the revisions that have the same sha1 hash:

            Source https://stackoverflow.com/questions/60480535

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install pywikibot

            You can install using 'pip install pywikibot' or download it from GitHub, PyPI.
            You can use pywikibot like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            Install
          • PyPI

            pip install pywikibot

          • CLONE
          • HTTPS

            https://github.com/wikimedia/pywikibot.git

          • CLI

            gh repo clone wikimedia/pywikibot

          • sshUrl

            git@github.com:wikimedia/pywikibot.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Consider Popular REST Libraries

            public-apis

            by public-apis

            json-server

            by typicode

            iptv

            by iptv-org

            fastapi

            by tiangolo

            beego

            by beego

            Try Top Libraries by wikimedia

            mediawiki

            by wikimediaPHP

            wikipedia-ios

            by wikimediaSwift

            apps-android-wikipedia

            by wikimediaKotlin

            composer-merge-plugin

            by wikimediaPHP

            jquery.i18n

            by wikimediaJavaScript