<span class="currentPrice-3131760660"><span content="800.00">800,00 $</span>
我正在尝试自动提取价格(在这种情况下为 800 美元)。然而,随着时间的推移,“currentPrice-”之后的数字发生变化,我的 Python 脚本停止工作。我正在使用这个 BeautifulSoup 功能:
soup.find_all('span', {'class' : 'currentPrice-3131760660'})
如何使用 find_all 提取类名称的部分匹配项,例如包含字符串“currentPrice-”的所有类?
最佳答案
你可以试试 CSS 选择器 soup.select('span[class*="currentPrice-"]')
关于python - 使用 Beautiful Soup 查找跨度中的部分类名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52842778/