英文:
python - Beautiful soup - get specific value in html not standard tag
问题
86
英文:
Fairly new to beautiful soup. Trying to parse this tag
html
<score-bill scoreA="86" audiencestate="upright" data-qa="score-panel" data-scoresmanager="scorebill:scoreAction" id="scoreboard" mediatype="assetseries" rating="" skeleton="panel" scoreb="98" assetstate="active">
Desired Results
86
Question
How do I parse the value in this tag?
Any help would be greatly appreciated
答案1
得分: 0
你可以使用find
来搜索标签。
html = '<score-bill scoreA="86" audiencestate="upright" data-qa="score-panel" data-scoresmanager="scorebill:scoreAction" id="scoreboard" mediatype="assetseries" rating="" skeleton="panel" scoreb="98" assetstate="active">'
soup = BeautifulSoup(html, 'lxml')
results = soup.find('score-bill')['scorea']
print(results) # 86
英文:
You can search the tag with find
html = '<score-bill scoreA="86" audiencestate="upright" data-qa="score-panel" data-scoresmanager="scorebill:scoreAction" id="scoreboard" mediatype="assetseries" rating="" skeleton="panel" scoreb="98" assetstate="active">'
soup = BeautifulSoup(html, 'lxml')
results = soup.find('score-bill')['scorea']
print(results) # 86
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论