Search
 
SCRIPT & CODE EXAMPLE
 

HTML

python split html header

from itertools import count

chapter_number = count(1)
output_file = open('000-intro.html', 'wb')

with open('index.html', 'rt') as input_file:
    for line in input_file:
        if '<h1' in line:
            output_file.close()
            output_file = open('{:03}-chapter'.format(next(chapter_number)), 'wb')
        output_file.write(line)

output_file.close()
Comment

PREVIOUS NEXT
Code Example
Html :: functioning search engine code 
Html :: barra di scorrimento orizzontale html 
Html :: text process bar wpf 
Html :: see locked pakages linux 
Html :: attach a script to a button html 
Html :: bootstrap modal delay closing on click outside 
Html :: how to use a text area for a model kendo mvc 
Html :: text -center bootstrape 
Html :: Como dividir texto 2 colunas em HTML 
Html :: keep favicon 
Html :: in line a frame animation 
Html :: http request for resource not found 
Html :: camerx mlkit barcode scanner 
Html :: selecting only one radio button 
Html :: meta og tags 
Html :: Bootstrap 5.0 Container 
Html :: count up timer in javascript 
Html :: html how to make a link traget a new window 
Css :: css placeholder font size 
Css :: css center elment screen 
Css :: google icon cdn 
Css :: smooth scroll to anchor 
Css :: styling scrollbar css 
Css :: css print landscape 
Css :: center an input css 
Css :: how to cover entire div with background image 
Css :: css elipsis 
Css :: css target except id 
Css :: div background image 
Css :: set scrollbar width css 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =