from bs4 import BeautifulSoup
import requests
import time
import keyboard
import re
def searchWiki():
search = input("What do you want to search for? ").replace(" ", "_").replace("'", "%27")
url = f"https://en.wikipedia.org/wiki/{search}"
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36'}
page = requests.get(url, headers=headers)
soup = BeautifulSoup(page.content, "html.parser")
title = soup.find("title").get_text()
info = soup.find_all("p")
print("Press enter to read the next paragraph")
print(title)
print(url)
for p in info:
print(p.text.strip())
keyboard.wait('enter')
searchWiki()
For example, search for Tom Holland. It should come up with this:
Thomas Stanley Holland (born 1 June 1996)[1] is an English actor. A graduate of the BRIT School in London...
Want I want to do is remove the refence number and the brackets.