from pywikibot.page import Link # Extract the first link from the page text link = Link.extract_links(page.text)[0] # Print the target page's title and namespace print("Target title:", link.title) print("Target namespace:", link.namespace)This code extracts the first link from the page text and creates a Link object for it. It then prints out the title and namespace of the target page. Package library: pywikibot