summaryrefslogtreecommitdiffstats
path: root/doc-publik/update-publik-doc-from-redmine.py
blob: 01c1a11971272c4d8f0cb8db75942a8805a667c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from bs4 import BeautifulSoup
import html5lib
import requests

from combo.data.models import TextCell

DOCS = {
    'passerelle-connecteur-dev': "https://dev.entrouvert.org/projects/passerelle/wiki/D%C3%A9veloppement_d'un_connecteur.html",
}

for cell in TextCell.objects.all():
    if not cell.slug in DOCS:
        continue
    resp = requests.get(DOCS[cell.slug])
    if resp.status_code != 200:
        continue
    document = BeautifulSoup(resp.content, 'html5lib')
    content = document.find('body')
    new_content = unicode(content).replace('<body>', '').replace('</body>', '')
    cell.text = new_content
    cell.save()