1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| from bs4 import BeautifulSoup
import re
info = """
<tr>
<th style="font-size:1.25em">
<span class="tipsy-trigger" original-title="Heure réelle d'émission :<br />02/08/2020<br /><b>00h00 UTC</b>">02h00</span> </th>
<td style="/*background-color:rgba(0,0,0,0.1)*/"><span title="" class="" style="font-weight:bold;display:inline-block;font-size:16px">17.3</span> <span class="tab-units-v">°C</span><span class="color-heatmap" style="background-color:rgb(255,211,30)"></span></td><td style="padding-left:8px; padding-right:8px;"></td><td style="/*background-color:rgba(0,0,0,0.1)*/">0 <span class="tab-units-v">mm/1h</span><span class="color-heatmap" style="background-color:rgb(255,255,255)"></span><br><a href="javascript:void(0)" style="opacity:0.3;" class="tipsy-trigger button-rr-pluvio" original-title="<table class='minitable-details' style='table-layout:fixed'><tr><td><b>Pluie/24h :</b></td><td>1.4mm</td></tr></table>"><span></span></a></td><td style="padding-left:20px; white-space: nowrap;"><span style="font-weight:bold">0</span> <span class="tab-units-v">m/s</span><br><span class="tab-units-v">raf.</span><span style="font-weight:bold">0</span> <div style="position: absolute; left:0px; top:50%; margin-top:-10px; height:20px; width:20px; background-image:url(//static.infoclimat.net/images/pictos_vent2/sprite.png); background-position: 240px 0px" class="tipsy-trigger" original-title="Vent de direction 7°">
</div></td><td style="/*background-color:rgba(0,0,0,0.1)*/"><span style="font-weight:bold;display:inline-block">96</span><span class="tab-units-v">%</span><span class="color-heatmap" style="background-color:rgb(4,129,175)"></span></td><td></td><td style="/*background-color:rgba(0,0,0,0.1)*/"><span style="font-weight:bold;display:inline-block">16.7</span> <span class="tab-units-v">°C</span><span class="color-heatmap" style="background-color:rgb(255,223,22)"></span></td><td>1019.1<span class="tab-units-v">hPa</span><span class="color-heatmap" style="background-color:rgb(239,255,51)"></span><br>=</td> </tr>
<tr>
<th style="font-size:1.25em">
<span class="tipsy-trigger" original-title="Heure réelle d'émission :<br />01/08/2020<br /><b>23h30 UTC</b>">01h30</span> </th>
<td style="/*background-color:rgba(0,0,0,0.1)*/"><span title="" class="" style="font-weight:bold;display:inline-block;font-size:16px">17.4</span> <span class="tab-units-v">°C</span><span class="color-heatmap" style="background-color:rgb(255,209,31)"></span></td><td style="padding-left:8px; padding-right:8px;"></td><td style="/*background-color:rgba(0,0,0,0.1)*/"></td><td style="padding-left:20px; white-space: nowrap;"><span style="font-weight:bold">0</span> <span class="tab-units-v">m/s</span><br><span class="tab-units-v">raf.</span><span style="font-weight:bold">0</span> <div style="position: absolute; left:0px; top:50%; margin-top:-10px; height:20px; width:20px; background-image:url(//static.infoclimat.net/images/pictos_vent2/sprite.png); background-position: 240px 0px" class="tipsy-trigger" original-title="Vent de direction 7°">
</div></td><td style="/*background-color:rgba(0,0,0,0.1)*/"><span style="font-weight:bold;display:inline-block">96</span><span class="tab-units-v">%</span><span class="color-heatmap" style="background-color:rgb(4,129,175)"></span></td><td></td><td style="/*background-color:rgba(0,0,0,0.1)*/"><span style="font-weight:bold;display:inline-block">16.7</span> <span class="tab-units-v">°C</span><span class="color-heatmap" style="background-color:rgb(255,223,22)"></span></td><td>1019.6<span class="tab-units-v">hPa</span><span class="color-heatmap" style="background-color:rgb(246,255,25)"></span><br><img class="tipsy-trigger" style="height:12px" src="https://static.infoclimat.net/images/v5.2/down.png" alt="baisse" original-title="-0.3 hPa/3h"></td> </tr>
<tr>
<th style="font-size:1.25em">
<span class="tipsy-trigger" original-title="Heure réelle d'émission :<br />01/08/2020<br /><b>23h00 UTC</b>">01h00</span> </th>
<td style="/*background-color:rgba(0,0,0,0.1)*/"><span title="" class="" style="font-weight:bold;display:inline-block;font-size:16px">17.6</span> <span class="tab-units-v">°C</span><span class="color-heatmap" style="background-color:rgb(255,206,34)"></span></td><td style="padding-left:8px; padding-right:8px;"></td><td style="/*background-color:rgba(0,0,0,0.1)*/">0 <span class="tab-units-v">mm/1h</span><span class="color-heatmap" style="background-color:rgb(255,255,255)"></span></td><td style="padding-left:20px; white-space: nowrap;"><span style="font-weight:bold">0</span> <span class="tab-units-v">m/s</span><br><span class="tab-units-v">raf.</span><span style="font-weight:bold">0</span> <div style="position: absolute; left:0px; top:50%; margin-top:-10px; height:20px; width:20px; background-image:url(//static.infoclimat.net/images/pictos_vent2/sprite.png); background-position: 240px 0px" class="tipsy-trigger" original-title="Vent de direction 7°">
</div></td><td style="/*background-color:rgba(0,0,0,0.1)*/"><span style="font-weight:bold;display:inline-block">96</span><span class="tab-units-v">%</span><span class="color-heatmap" style="background-color:rgb(4,129,175)"></span></td><td></td><td style="/*background-color:rgba(0,0,0,0.1)*/"><span style="font-weight:bold;display:inline-block">17.2</span> <span class="tab-units-v">°C</span><span class="color-heatmap" style="background-color:rgb(255,213,29)"></span></td><td>1019.9<span class="tab-units-v">hPa</span><span class="color-heatmap" style="background-color:rgb(246,255,25)"></span><br>=</td> </tr>
<tr>
</body>
</html>
"""
soup = BeautifulSoup(info,features="html.parser")
heure = list()
#heure, temperature, vitesse vent, vitesse raffale, direction, humidité, pt rosée, pression
count = 0
for p in soup.find_all('div'):
print(count,p)
print(re.findall('direction.*?style', p.text))
count+=1
print(soup.get_text()) |
Partager