I have an html file and I am parsing it with regular expressions. I don't want to use any python html libraries, because I am not using it as a website, but as a configuration type file. I am making a basic bookmarks system, the parser works fine, so I guess my question is about the second part, writing to the files. The file looks like this
<html>
<head>
<title>my bookmarks</title>
</head>
<body>
<div id="smalltalk">
<a href="http://www.smalltalk.org">Smalltalk.org</a>
</div>
<div id="python">
<a href="http://www.python.org">Python.org</a>
</div>
</body>
</html>
My parser call the div's sections, and I want to write a method to insert more sections before the /body and /html tags.
The question, without all of my other information is, how do I INSERT text into a file with python, without deleting the text after it.