i don't understand how work encodage with python.
import json
from bs4 import BeautifulSoup
soup = BeautifulSoup('A lot of HTML here', 'html.parser')
rec_titre = soup.find_all("div", {"class": "c-toparticle__title"})
trait_titre = rec_titre[0].text.replace("\n", '').strip()
dataEcho.append({'Titre': trait_titre, 'content': trait_content, 'uri': "https://www.lecho.be" + rec_uri})
with open('data.json', 'w') as outfile:
json.dump(dataEcho, outfile, sort_keys=True, indent=4, separators=(',', ': '))
result in my Json file :
[
{
"Titre": "Amay | Vers un troisi\u00c3\u00a8me mandat pour Jean-Michel Javaux",
"content": "L\u00e2\u0080\u0099ex copr\u00c3\u00a9sident d\u00e2\u0080\u0099Ecolo a demand\u00c3\u00a9 (et obtenu) une d\u00c3\u00a9rogation de son parti Ecolo pour pouvoir briguer un nouveau mandat ma\u00c3\u00aforal.",
"uri": "https://www.lecho.be/dossier/zoom-communal/amay-vers-un-troisieme-mandat-pour-jean-michel-javaux/10032845.html"
}
]
EDIT :
I have been looking for this morning impossible to find. I am in python3
Code here || Just would like have utf-8 in my json...
Json :
[
{
"Titre": "Amay | Vers un troisième mandat pour Jean-Michel Javaux",
"content": "Lâex coprésident dâEcolo a demandé (et obtenu) une dérogation de son parti pour pouvoir briguer un nouveau mandat maïoral.",
"uri": "https://www.lecho.be/dossier/zoom-communal/amay-vers-un-troisieme-mandat-pour-jean-michel-javaux/10032845.html"
}
]