From: Steven W. Orr on
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

From: Miki on
On Aug 7, 7:42 pm, "Steven W. Orr" <ste...(a)syslang.net> 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?
Have a look at http://www.crummy.com/software/BeautifulSoup/.

All the best,
--
Miki <miki(a)mikitebeka.com>
http://mikitebeka.com
The only difference between children and adults is the price of the
toys
From: Chris Rebert on
On Sat, Aug 7, 2010 at 7:42 PM, Steven W. Orr <steveo(a)syslang.net> 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?

Certainly not mod_python; that project is dead. mod_wsgi is the
suggested replacement.
But both are relatively low-level solutions. Python has myriad web
frameworks available for it; have a look at them.

Cheers,
Chris
--
http://blog.rebertia.com
From: Steven W. Orr on
On 08/07/10 23:57, quoth Miki:
> On Aug 7, 7:42 pm, "Steven W. Orr" <ste...(a)syslang.net> 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?
> Have a look at http://www.crummy.com/software/BeautifulSoup/.

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

From: Thomas Jollans on
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