update update.py
This commit is contained in:
parent
7e8836699b
commit
a742cf2873
1 changed files with 8 additions and 3 deletions
11
update.py
11
update.py
|
@ -6,6 +6,9 @@ import ox
|
|||
api = ox.API('https://indiancine.ma/api/')
|
||||
doc = api.getDocument(id='DWA')['data']['text']
|
||||
|
||||
indent = ' '
|
||||
indent_s = ' '
|
||||
|
||||
section_html = []
|
||||
menu_html = []
|
||||
for section in doc.split('<h1>')[1:]:
|
||||
|
@ -13,11 +16,13 @@ for section in doc.split('<h1>')[1:]:
|
|||
name = title.lower()
|
||||
html = section[section.index('</h1>')+5:]
|
||||
menu_html.append('<a href="#{}">{}</a>'.format(name, title))
|
||||
section_html.append(' <div class="section" id="{}">{}\n </div>'.format(name, html))
|
||||
html = html.replace('<br><br>', '').replace('<p></p>', '')
|
||||
html = '\n'.join([indent + r for r in html.strip().split('\n')])
|
||||
section_html.append(indent_s + '<div class="section" id="{}">\n{}\n{}</div>'.format(name, html, indent_s))
|
||||
|
||||
section_html = '\n'.join(section_html)
|
||||
menu_html = '<div id="menu">\n ' + ' ·\n '.join(menu_html) + '\n </div>\n'
|
||||
menu_html += ' <a id="link" target="_blank"></a>\n'
|
||||
menu_html = '<div id="menu">\n' + indent + (' ·\n' + indent).join(menu_html) + '\n'+indent_s+'</div>\n'
|
||||
menu_html += indent_s + '<a id="link" target="_blank"></a>\n'
|
||||
|
||||
with open('index.html') as fd:
|
||||
index = fd.read()
|
||||
|
|
Loading…
Reference in a new issue