Bonjour à tous,
je tente de récupérer les données d'un tableau d'une page web. J'ai cru comprendre que Beautiful soup était un outil pour ce genre de manip.
Je souhaiterais créer une liste par ligne du tableau avec les valeurs numériques dans l'idéal. voici ce que j'ai :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 :&lt;br /&gt;02/08/2020&lt;br /&gt;&lt;b&gt;00h00 UTC&lt;/b&gt;">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="&lt;table class='minitable-details' style='table-layout:fixed'&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;Pluie/24h :&lt;/b&gt;&lt;/td&gt;&lt;td&gt;1.4mm&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;"><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 :&lt;br /&gt;01/08/2020&lt;br /&gt;&lt;b&gt;23h30 UTC&lt;/b&gt;">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 :&lt;br /&gt;01/08/2020&lt;br /&gt;&lt;b&gt;23h00 UTC&lt;/b&gt;">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())
je récupére donc ceci :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
0 <div class="tipsy-trigger" original-title="Vent de direction 7°" 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">
</div>
[]
1 <div class="tipsy-trigger" original-title="Vent de direction 7°" 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">
</div>
[]
2 <div class="tipsy-trigger" original-title="Vent de direction 7°" 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">
</div>
[]
 
 
 
02h00 
17.3 °C0 mm/1h0 m/sraf.0 
96%16.7 °C1019.1hPa= 
 
 
01h30 
17.4 °C0 m/sraf.0 
96%16.7 °C1019.6hPa 
 
 
01h00 
17.6 °C0 mm/1h0 m/sraf.0 
96%17.2 °C1019.9hPa=
Je souhaite donc avoir ceci, une liste de tuple par ligne:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
[('02h00', '17.3 °C', '0 mm/1h', '0 m/s', 'raf.0 ', '7°', '96%', '16.7 °C', '1019.1hPa'), ('01h30', '17.4 °C', '0 mm/1h', '0 m/s', 'raf.0 ', '7°', '96%', '16.7 °C', '1019.6hPa'), ('01h00', '17.6 °C', '0 mm/1h', '0 m/s', 'raf.0 ', '7°', '96%', '17.2 °C', '1019.9hPa')]
A savoir que la direction est la légende d'une image que je tente d'isoler avec un regex.
Ma première question est : suis sur la bonne voie ?
Ma deuxième est : si oui, de quelle manière puis isoler mes valeurs numériques pour construire mes tuples de préférence sans les unités ^^.

Je cherche dans la doc de beautifulsoup sans trouver ou comprendre quelles autres méthodes utiliser...
Je me casse les dents sur le regex aussi.

merci de vos retours