1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
#links_with_text = []
#soup = BeautifulSoup(page.content, 'html.parser')
listes = soup.find_all('article', class_="Formation")
#with open('housing.csv', 'w', encoding='utf8', newline='') as f:
# thewriter = writer(f)
# header = ['Intitule', 'OF', 'Session', 'Prochaine Session', 'Ville', 'Duree']
for liste in listes :
intitule = liste.find('a', href=True).text.strip()
#print(intitule)
of = liste.find('div', class_='Formation-organism').text.strip()
#print(of)
session = liste.find('div', class_='Formation-sessions').text.strip()
#print(session)
prochaine_session = liste.find('div', class_='Formation-nextsession')
villeHeures = liste.find(['div'], class_ = 'Formation-details')
if prochaine_session is not None:
#print(prochaine_session.text)
print(prochaine_session.text.replace('Prochaine session :','').strip())
if villeHeures is not None:
print(villeHeures.text.strip())
info = [intitule, of, session, prochaine_session.text.replace('Prochaine session :','').strip(), villeHeures.text.strip()]
print(info) |
Partager