I am trying to create a simple web scraper that will return the list of names from this website: https://www.verywellfamily.com/top-1000-baby-girl-names-2757832 However, I cannot figure out how to get them in a 'clean' format. This code below returns the names, but all the tags are still with it.
import requests
import urllib.request
from bs4 import BeautifulSoup
URL = 'https://www.verywellfamily.com/top-1000-baby-girl-names-2757832'
page = requests.get(URL)
soup = BeautifulSoup(page.content, 'html.parser')
names = soup.find(id='mntl-sc-block_1-0-13')
print(names)
This code is to put it into a file:
file_name = URL.rsplit('/',1)[1].rsplit('.')[0]
with open('./{}.txt'.format(file_name), mode='wt', encoding='utf-8') as file:
file.write((names))