从html代码中获取数据

I need to store some information from an html with bash or php

Part of the code in htm is

</script>
</div>
</div>
</div>
<div class="datastation">
<div class="bit-66">
<div id="resum-diari" style="position:relative">
<h5>Daily Summary
</h5>
<div class="table">
<table summary="Weather Data today">
<tbody>
<tr>
<th>Temperature max</th>
<td>

10.5 °C



</td>
<tr>
<th>Temperature min</th>
<td>  


0.1 °C



</td>
<tr>
<th>Precipitation</th>
<td colspan="2">


0.8 mm



</td>
</tr>
</tbody>
</table>
</div>
<script type="text/javascript">
$(document).ready(function() {
$('#nameStation').html('Oslo');
$('#dataToday').html('03.12.2014');
</script>
</div>
</div>
<h4>Oslo</h4>
<table summary="Current Weather">
<tr>
<th>City</th>
<td>Oslo</td>
</tr>
<tr>
<th>Country</th>
<td>Norway</td>
</tr>
<tr>
<th>Height</th>
<td>15 m</td>
</tr>
</table>

And I need to store in a csv, the next data

City, Temperature max, Temperature min, Precipitation
Oslo, 10.5,0.1,0.8

Can you help me?

I have tried with this code, but something in this case doesn't run

awk -F'<|>' -v OFS="," 'NF>3{if (r) {r=r OFS $3} else r=$3} /tr/ {print r; r=""}' $dir/Oslo.htm

It is solved! I have used Grep -A 3 'Temperature max' data.htm > data.txt and then I use awk, tmax=`awk 'NR == 4' tmax.txt.... – Enric Agud Pique