You can try using the re module for regexes, but regexes are probably overkilled for what you want. You can do something like this:
z.write(article[:article.index("</html>") + 7]
This will be much cleaner and should be much faster than a regex-based solution.