[Tutor] Modifying files in a directory.
qsqgeekyogdty at tiscali.co.uk
qsqgeekyogdty at tiscali.co.uk
Thu May 29 10:17:40 CEST 2008
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
More information about the Tutor
mailing list