27 lines
703 B
Python
27 lines
703 B
Python
import requests
|
|
from bs4 import BeautifulSoup
|
|
import json
|
|
|
|
url = "https://fr.wiktionary.org/wiki/Wiktionnaire:Liste_de_1750_mots_fran%C3%A7ais_les_plus_courants"
|
|
response = requests.get(url)
|
|
soup = BeautifulSoup(response.content, 'html.parser')
|
|
|
|
word_list = soup.find_all('a')
|
|
word_freq = {}
|
|
|
|
for word in word_list:
|
|
text = word.text.strip()
|
|
if text:
|
|
print(text)
|
|
#print("\n")
|
|
|
|
# # Initialise la fréquence de chaque mot à 1 pour les trier plus tard
|
|
# for word in word_freq:
|
|
# word_freq[word] = 1
|
|
#
|
|
# # Convertit le dictionnaire en JSON
|
|
# json_data = json.dumps(word_freq)
|
|
#
|
|
# # Écrit le JSON dans un fichier
|
|
# with open('word_freq.json', 'w') as f:
|
|
# f.write(json_data)
|