pywikibot.page is a module of the Python package pywikibot, which is used to interact with the MediaWiki wikis, such as Wikipedia. This module provides a way to create, retrieve and modify page objects on the wiki.
Example 1: Creating a new page on Wikipedia
import pywikibot
# Login to Wikipedia using username and password site = pywikibot.Site("en", "wikipedia") site.login()
# Create a new page object titled "My New Page" new_page = pywikibot.Page(site, "My New Page")
# Add content to the page new_page.text = "This is the content of my new page."
# Save the page new_page.save("Creating a new page.")
In this example, we create a new page object on the English Wikipedia with the title "My New Page", add some content to it, and save it with a summary message.
Example 2: Retrieving the text of an existing page
import pywikibot
# Login to Wikipedia using username and password site = pywikibot.Site("en", "wikipedia") site.login()
# Get the page object of the Wikipedia article about Python python_page = pywikibot.Page(site, "Python (programming language)")
# Print the text of the page print(python_page.text)
In this example, we retrieve the page object of the Wikipedia article about Python, and print its text.
Package library: pywikibot.
Python Link.Link - 30 examples found. These are the top rated real world Python examples of pywikibot.page.Link.Link extracted from open source projects. You can rate examples to help us improve the quality of examples.