多个标签,我有以下HTML使用BeautifulSoup与同名
<g class="1581 sqw_sv5" style="cursor: pointer;">
<path d="M397.696,126.554C397.696,126.554,404.57504,140.2417375,404.57504,140.2417375" stroke="#ffffff" style="stroke-width: 3.6; stroke-opacity: 0.5; stroke-linecap: round; fill-opacity: 0;">
</path>
<path d="M397.696,126.554C397.696,126.554,404.57504,140.2417375,404.57504,140.2417375" stroke="#f95a0b" style="stroke-width: 1.2; stroke-linecap: round; fill-opacity: 0;">
</path>
我需要在第二路径获得“抚摸”的价值。我现在的代码只是从第一个路径中提取值。
我目前使用
shots = soup.find_all('g')
for shot in shots:
print(shot.path['stroke'])
返回#FFFFFF。我需要它返回#f95a0b
是否总是第二路径? –