HTML Generation

Stefan Behnel stefan_ml at behnel.de
Fri Apr 3 10:59:20 EDT 2009


J Kenneth King wrote:
> from tags import html, head, meta, title, body, div, p, a
> 
> mypage = html(
>              head(
>                  meta(attrs={'http-equiv': "Content-Type",
>                              'content': "text/html;"}),
>                  title("My Page")),
>              body(attrs={'background': "#ffffff;"},
>                  div(attrs={'id': "article-content"},
>                      p(a(attrs={'href': "http://python.org"},
>                                 "Python.org")))))
> 
> tabbed_file(mypage, open('myfile.html', 'w'))

See here for another example that uses lxml.html:

http://codespeak.net/lxml/lxmlhtml.html#creating-html-with-the-e-factory

Stefan



More information about the Python-list mailing list