1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
from urllib.request import urlopen
from bs4 import BeautifulSoup
urls = [
'https://fr.wikipedia.org/wiki/Langue',
'https://fr.wikipedia.org/wiki/Liste_de_langages_de_programmation',
'https://fr.wikipedia.org/wiki/Langage_de_programmation',
'https://fr.wikipedia.org/wiki/Registre_de_langue',
'https://fr.wikipedia.org/wiki/Acquisition_du_langage',
'https://fr.wikipedia.org/wiki/Parole',
'https://fr.wikipedia.org/wiki/Trouble_du_langage'
]
for url in urls:
bs = BeautifulSoup(urlopen(url), "html.parser")
titles = bs.find_all(['title', 'h1', 'h2','h3','h4','h5','h6','p','img','alt'])
print('List all the header tags :', *titles, sep='\n\n') |
Partager