I need a starter ptr writing python embedded in html.

S

Steven W. Orr

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?

TIA

--
Time flies like the wind. Fruit flies like a banana. Stranger things have .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.10 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAkxeGZEACgkQRIVy4fC+NyRdhgCfTTdsOp93sXQJ1KPGE+1OejeC
HAoAn21HCBQljQYbIiQ+Tb/qELNa20O6
=a7Wt
-----END PGP SIGNATURE-----
 
M

Miki

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?
Have a look at http://www.crummy.com/software/BeautifulSoup/.

All the best,
 
S

Steven W. Orr


Thanks. But what I'm not seeing is any example of how to make this allowed to
generate the html at run time. I think I want to embed my python code into an
html file. Beautiful soup seems to allow me to create a preprocessor which I
could use through a Makefile to generate the html. I have the feeling I'm
missing something. Or do I use this in conjunction with wsgi?

--
Time flies like the wind. Fruit flies like a banana. Stranger things have .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.10 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAkxevXkACgkQRIVy4fC+NyR7iQCfU0hB8UyofhbbiEsWCrU/54nH
dV0An1eORVbg6QJ50zTWMcnc7NffGph8
=7Nu/
-----END PGP SIGNATURE-----
 
M

Miki

I'm ok in python but I haven't done too much with web pages. I have a web page
Thanks. But what I'm not seeing is any example of how to make this allowed to
generate the html at run time.
Oh, I misunderstood you. You probably want one of the templating
systems out there, such as Mako, Jinja2, Cheetah, ...

Maybe http://cherrypy.org/wiki/intro/1 will be of help.

All the best,
 
A

alex23

Steven W. Orr said:
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 [into html]

Is the data coming from somewhere like a file or db? If so, I'd just
use something simple like this html generator:

http://pypi.python.org/pypi/html

It's a very clever use of context managers to handle element
nesting :)

If the data doesn't change very often, I'd just write a simple script
that parses the data source and builds a html page to server
statically. If it does, it's not much extra to convert that to a WSGI
script that returns the html string rather than creating a static
file.

I use this approach to produce a browseable table from a folder full
of files with fixed-pattern names.

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top