#!/usr/bin/python3 from collections import OrderedDict 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('

')[1:]: title = section[:section.index('

')] name = title.lower() html = section[section.index('')+5:] menu_html.append('{}'.format(name, title)) html = html.replace('

', '').replace('

', '') html = '\n'.join([indent + r for r in html.strip().split('\n')]) section_html.append(indent_s + '
\n{}\n{}
'.format(name, html, indent_s)) section_html = '\n'.join(section_html) menu_html = '\n' menu_html += indent_s + '\n' with open('index.html') as fd: index = fd.read() head = index[:index.index('