0
하는 HTML 코드에서 데이터를 가져나는 떠들썩한 파티 또는 PHP가있는 HTML에서 몇 가지 정보를 저장해야
HTM의 코드의 일부는
</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>
입니다 그리고 나는를 CSV에 저장해야 할 다음 데이터
City, Temperature max, Temperature min, Precipitation
Oslo, 10.5,0.1,0.8
도와 주시겠습니까?
나는이 코드를 시도하지만,이 경우에는 뭔가 그것은 해결
awk -F'<|>' -v OFS="," 'NF>3{if (r) {r=r OFS $3} else r=$3} /tr/ {print r; r=""}' $dir/Oslo.htm
try PHP 간단한 HTML DOM 파서 simplehtmldom.sourceforge.net –
나는 ['xmllint'] (http://man.cx/xmllint)를 권하고 싶었지만 웹 사이트에서 제공 한'html'은'xml'이 아닙니다. (예 : 닫히지 않은 img 또는 br 태그 ...) xhtml 데이터의 경우 xmllint는'xml'처럼 작동합니다 .. – anishsane
이것은 awk와 같은 도구가 아닌 HTML 파서에 적합한 작업입니다. 질문을 할 때 HTML을 정돈하여 구조를 명확하게해야합니다 - 왜 그 페이지 아래쪽의 '
'이 위의 데이터와 관련이 있는지 분명하지 않습니다. –