I need a starter ptr writing python embedded in html.

Thomas Jollans thomas at jollybox.de
Sun Aug 8 13:33:34 EDT 2010


On Sunday 08 August 2010 04:42:25 Steven W. Orr wrote:
> I'm ok in python but I haven't done too much with web pages. I have a web
> page that is hand written in html that has about 1000 entries in a table
> and I want to convert the table from entries like this
> 
>     <tr>
>       <td> Some Date String </td>
>       <td> SomeTag </td>
>       <td>
> 	<a href="localSubdir"> A Title </a>
>       </td>
>       <td>
> 	<a href="http://www.example.com/remote/path/something.html"
> 	  Click
> 	</a>
>       </td>
>       <td> Some Comment </td>
>     </tr>
> 
> to
> 
>    SomePythonCall('Some Date String',
> 		'SomeTag',
> 		'localSubdir',
> 		"http://www.example.com/remote/path/something.html",
> 		'Click',
> 		'Some Comment')
> 
> Can someone tell me what I should look at to do this? Is mod_python where I
> should start or are there things that are better?

I'm a bit confused about what you're actually asking. If you have a long, HTML 
file you want to convert to something else (like Python code...), then 
BeautifulSoup will help you do that - you can use it to parse the original 
file, and thus make it easier to do the conversion.

If your question was "how do I use Python to create web sites":
You don't embed Python in HTML. I doubt anybody does this seriously -- Python 
(with indentation-based scoping) is less well-suited for this than PHP or 
Ruby, and it's better to keep logic and presentation separate anyway.

"The" standard for using Python on the web is WSGI -- it's a very simple, low-
level interface between Python and the web server. There are a number of 
higher-level web frameworks that you might want to look at if your project is 
sufficiently complex. [1]

 -- Thomas


[1] http://wiki.python.org/moin/WebFrameworks





More information about the Python-list mailing list