[Tutor] Modifying files in a directory.

Chester wxpythoner at gmail.com
Thu May 29 11:05:09 CEST 2008


please correct this
from BeautifulSoup import BeautifulSoup
to be
from BeautifulSoup import BeautifulStoneSoup

On Thu, May 29, 2008 at 10:17 AM, qsqgeekyogdty at tiscali.co.uk <
qsqgeekyogdty at tiscali.co.uk> wrote:

> Hi,
> >From my previous post, I have tis so far:
>
> [code]
> import os
> from BeautifulSoup import BeautifulSoup
>
>
> rootdir='/home/david/test'
>
> def upDateTable(line):
>    soup = BeautifulSoup(''.join(file))
>
>
>    return line
>
> for subdir, dirs, files in os.walk(rootdir):
>    for file in files:
>        f=open(file, 'r')
>        lines=f.readlines()
>        f.close()
>        f=open(file, 'w')
>        for line in lines:
>            newline=upDateTable(line)
>            f.write(newline)
>        f.close()
>
> [/code]
>
> In each html file I have this table, which I want to modify:
>
> [code]
> <table align="center" cellpadding="0" cellspacing="0" class="
> tbl_left_inside" >
> <tr >
> <td class="tbl_left_report_name">PV Clad Analysis</td>
> </tr>
> <tr>
> <td class="table_package">200</td>
> </tr>
> <tr>
> <td class="tbl_price">$79.99</td>
> </tr>
> </table>
>
> [/code]
>
> So the table has a class="tbl_left_inside"  and I want to update the
> <td class="tbl_price">$79.99</td> so that the price is reduced by 15%
>
> And I want to add a new <td class="tbl_buy"><a href="buy.cgi">Buy Now!
> </a></td>
>
> Thanks
> David
>
>
>
> ________________________
> What can Tiscali do for you? http://www.tiscali.co.uk/services
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20080529/bf11acdd/attachment.htm>


More information about the Tutor mailing list