doc-publik: add script to update doc-publik from mallard pages

This commit is contained in:
Frédéric Péters 2017-06-25 17:53:01 +02:00
parent 85820cbaea
commit 7ab54b5153
1 changed files with 20 additions and 0 deletions

View File

@ -0,0 +1,20 @@
from bs4 import BeautifulSoup
import html5lib
import requests
from combo.data.models import TextCell
for cell in TextCell.objects.all():
if not cell.slug.startswith('mallard-'):
continue
mallard_page = cell.slug.split('-', 1)[1]
for module in ('wcs', 'publik-base-theme'):
resp = requests.get('https://doc.entrouvert.org/%s/dev/%s.html' % (module, mallard_page))
if resp.status_code != 200:
continue
document = BeautifulSoup(resp.content, 'html5lib')
content = document.find('div', 'body')
more_info = document.find('div', 'sect sect-links')
new_content = unicode(content).replace(unicode(more_info), '')
cell.text = new_content
cell.save()