我有一个网站https://dip.bundestag.de/aktivit%C3%A4t/Dr--Holger-Becker-MdB-SPD/1628877,我想提取的网页连接到"BT-PlenarProtokoll 20/86,S.10313C".该HTML块是:
<a title="PDF Bundestags-Plenarprotokoll öffnen" aria-label="BT-Plenarprotokoll" href="https://dserver.bundestag.de/btp/20/20086.pdf#P.10313" target="_self" class="hsbfb4-0 sc-1xaeas4-1 hTYfHF FZiNn"><svg viewBox="0 0 10 12" class="sc-1c5ggr5-17 cYBAUx"><g stroke="currentColor" fill="none" fill-rule="evenodd"><path d="M6.14.5H.5v11h9V3.86z"></path><path d="M5.56 2.01v2.51H9.5"></path></g></svg><span class="sc-1xaeas4-3 iZuhXx">BT-Plenarprotokoll 20/86, S. 10313C</span></a>
出于任何原因,BeautifulSoup无法识别此网页上的任何标签.我试过不同的代码:
from bs4 import BeautifulSoup
url = "https://dip.bundestag.de/aktivit%C3%A4t/Dr--Holger-Becker-MdB-SPD/1628877"
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
# Find the anchor tag with title 和 aria-label attributes 和 extract the href attribute
a_tag = soup.findAll('a', {'title': 'PDF Bundestags-Plenarprotokoll öffnen', 'aria-label': 'BT-Plenarprotokoll'})
和
url = "https://dip.bundestag.de/aktivit%C3%A4t/Dr--Holger-Becker-MdB-SPD/1628877"
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
# Find the anchor tag with title 和 aria-label attributes 和 extract the href attribute
a_tag = soup.findAll('a')
In both cases, a_tag is an empty object, 和 I don't underst和, since this webpage has more than one link.