Friday, 26 January 2024

Edit article using PAWS

Bot Editing in Wikipedia

 

1.      Use Paws

https://hub-paws.wmcloud.org

 

2.      Log in

3.      Need 2 files : 1. Terminal   2. Txt file ( For eg: Test.txt)

4.      Enter the codes in Test.txt file

( Example:

 

 {{-start-}}

'''Article Title' 

Introduction of article

 

==History==

Need to enter content here

 

{{-stop-}}

 

5.      Come back to terminal and log in to your wiki for example:

@PAWS:~$ pwb.py login -lang:ml -family:wikipedia

6.      Then execute your test.txt file as given below

pwb.py pagefromfile -file:/home/paws/test.txt -lang:ml -family:wikipedia -force

 

This is to add content in the existing article.

 ----------------------------Part 2-------------------

Adding Category



import pywikibot


def add_category_to_article(page_title, category):

    site = pywikibot.Site('ml', 'wikipedia')  # Malayalam Wikipedia

    page = pywikibot.Page(site, page_title)


    # Check if the page exists

    if not page.exists():

        print(f"Page '{page_title}' does not exist.")

        return


    # Check if the page already has the category

    if category in page.categories():

        print(f"Page '{page_title}' already has the category '{category}'.")

        return


    # Add the category to the page

    page.text += f"\n[[വർഗ്ഗം:{category}]]"

    page.save(f"Adding category '{category}' to the page")


def main():

    articles = [

        "അഡിനോഫൈബ്രോമ",

        "അഡിനോമയോസിസ്",

        "ഒവേറിയൻ_ഫൈബ്രോമ",

        "ഒവേറിയൻ_സിസ്റ്റാഡിനോമ",

        "ഒവേറിയൻ_സീറസ്_സിസ്റ്റാഡിനോമ",

        "ഓപ്സോമെനോറിയ",

        "ഗർഭാശയ_പോളിപ്പ്",

        "ജനനേന്ദ്രിയ_അരിമ്പാറ",

        "ജയന്റ്_കോണ്ടൈലോമാ_അക്യൂമിനേറ്റം",

        "ജേം_സെൽ_ട്യൂമർ",

        "ജോൺ_സ്പിയേഴ്‌സ്",

        "മയോമ",

        "വജൈനൽ_യീസ്റ്റ്_ഇൻഫെക്ഷൻ"

    ]


    category = "രോഗങ്ങൾ"


    for article in articles:

        add_category_to_article(article, category)


if __name__ == "__main__":

    main()

0 comments:

Post a Comment