Code: Alles auswählen
import sys
text = """<b>buffer</b>
<form>
lalala
lululu
</form>
buffer
<form>
buffer
</form>
alla"""
istrue = False
liste = []
form1 = ""
for el in xrange(len(text)):
    if istrue:
        if text[el] == "<":
            if text[el + 1] == "/" and text[el + 2] == "f" and text[el + 3] == "o" and text[el + 4] == "r" \
                        and text[el + 5] == "m" and text[el + 6] == ">":
                            form1 = form1 + "</form>"
                            istrue = False
                            liste.append(form1)
                            form1 = ""
                            continue
                            
        form1 = form1 + text[el]
    if text[el] == "<":
        if text[el + 1] == "f" and text[el + 2] == "o" and text[el + 3] == "r" and text[el + 4] == "m":
            istrue = True
            form1 = form1 + "<"Aber er funktioniert.
 
 Da dieser Code so schwer lesbar ist schreibe ich mal die Ausgabe hin:
Code: Alles auswählen
>>> liste
['<form>\nlalala\nlululu\n</form>', '<form>\nbuffer\n</form>']Geht das?
MfG INFACT
EDIT: Code aufgebessert...


 Was du suchst ist ein HTML - PARSER.
 Was du suchst ist ein HTML - PARSER.
 
 