from bs4 import BeautifulSoup import requests import re url = "https://en.wikipedia.org/wiki/List_of_Middle-earth_characters" # Get the contents of the webpage in text format data = requests.get(url).text soup = BeautifulSoup(data,"html.parser") # Parse the HTML code to isolate rows containing character names names = soup.find_all('li') # Apply a second filter to isolate actual names names_2 = [] for i in names: if """