Hi i would like to code me a small helper Tool in Python it should process the following content:
<tr>
<td><p>L1</p></td>
<td><p>(4.000x2.300x500; 4,6m³)</p></td>
<td><p> </p></td>
<td><p> 1.221 kg</p></td>
</tr>
<tr>
<td><p>L2</p></td>
<td><p>(4.250x2.300x500; 4,9m³)</p></td>
<td><p> </p></td>
<td><p> 1.279 kg</p></td>
</tr>
<tr>
<td><p>L3</p></td>
<td><p>(4.500x2.300x500; 5,2m³)</p></td>
<td><p> </p></td>
<td><p> 1.321 kg</p></td>
</tr>
<tr>
<td><p>L4</p></td>
<td><p>(4.750x2.300x500; 5,5m³)</p></td>
<td><p> </p></td>
<td><p> 1.364 kg</p></td>
</tr>
It should replace the of each table row with the the volume in this case everthing between the ; and the ) in the second table data field of each row.
i started to code it in python like that and i could allready scrape the Volume with a regex statement but my logic ends on how to put the values on the right place. any idea ? here is my code
import BeautifulSoup
import re
with open('3mmcontainer.html') as f:
content = f.read()
f.close()
#print content
contentsoup = BeautifulSoup.BeautifulSoup(content)
for tablerow in contentsoup.findAll('tr'):
inhalt = str(tablerow.contents[3])
print inhalt
match = re.findall('\;(.*?)\)', inhalt)
print match
# for x in match:
# volumen = x.lstrip()
# print volumen
#f = open('3mmcontainer.html', 'w')
#newdata = f.replace(" ", volumen)
#f.write(newdata)
#f.close()
#m = re.search('\;(.*?)\)', inhalt)
# print m
# volumen = re.compile(r'\;(.*?)\)')
# volumen.match(tablerow.contents[3])