DEV Community

Lyokolux
Lyokolux

Posted on • Originally published at blog.lyokolux.space on

1 1

Supprimer un billet de blog, ça tourne mal

J'ai supprimé par inadvertance mon fichier markdown sur l'article CUL 0b11 avec un bon rm cul-3.md. Le fail, j'ai validé la commande plus vite que mon ombre facepalm.

meme

Comment s'en sortir et le retrouver, sans backup ?

Heureusement Python est mon ami. L'idée est simple : récupérer le code source de l'article, directement depuis le site. Je prends la partie qui m'intéresse.

Puis avec une recherche internet, je tombe sur html2text. Un coup de pip3 install et hop je suis parti pour un one-liner dégueulasse :

import html2text
open('cul-3.md', 'w').write(html2text.html2text(open('article-en-html').read()))

Enter fullscreen mode Exit fullscreen mode

Et voilà, je retrouve mon article correctement nommé. Plus quà retrouver les metadonnées de l'article en 30 secondes et c'est bon. Boulette réparée.
Après test sur un serveur en local (merci
python -m http.server`), il est de nouveau là. J'aime l'informatique.

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay