Bonjour,
je ne parviens pas à attraper la valeur d'un attribut.
voici le html simplifié :je voudrais la valeur de base64Binary xmlnsje m'y prend ainsi (je mets find_all pour montrer la liste vide)
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 <!DOCTYPE html> <html> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type"/> </head> <body> <p hidden="hidden"> <!-- <TITLE>Login</TITLE> <a href="jpg.html">LIVE JPEG</a><br> <a href="liveie.html">Internet Monitor (Microsoft Internet Explorer 8, 9, 10, 11) </a><br> <a href="DVRRemoteAP.exe">Download 32 bits DVR Client (Windows 7, Windows 8, Windows 10)</a><br> <a href="DVRRemoteAP_X64.exe">Download 64 bits DVR Client (Windows 7, Windows 8, Windows 10)</a><br> <a href="DVFPlayer.zip">Download 32/64 bits File Player (Windows 7, Windows 8, Windows 10)</a><br> <\?xml version="1.0" encoding="utf-8"?><base64Binary xmlns="http://micros-hosting.com/EGateway/"> Location: /admin <meta name="generator" content="vBulletin 5.5.4" /> ... base64Binary</base64Binary> ... </body></html>et j'obtiens
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 from bs4 import BeautifulSoup as bs with open('/home/nbah/fichier.html', "r") as f: content = f.read() soup = bs(content,'html.parser') soup.find_all('base64Binary', attrs={'xmlns'})
Code : Sélectionner tout - Visualiser dans une fenêtre à part []est-ce parce ce que la balise est dans un commentaire ? et/ou comment faire ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 >>> 'base64Binary' in content True
Partager