Strip Html 标签 Findall + Beautiful Soup

Strip Html Tags Findall + Beautiful Soup

好吧,我已经搜索了大约 2 个小时,我相信我的大脑可能只是炸了。今天是我与 BeautifulSoup 的第一天(所以请保持温柔)。我正在抓取的网站源代码格式如下:

<a href="/listing/view" class="price">0</a>

我觉得很蠢,因为我在写入文件时得到了整个 a 标签,我暗暗怀疑有这么简单的解决方案,但我似乎找不到它。

目前我使用的是:

soup = BeautifulSoup(page.content, 'html.parser')
prices = soup.find_all(class_="price")
passed.append(prices)

如何才能仅定位特定标签之间匹配 类 的内容?

prices = soup.find_all(class_="price")

for a in prices:
  passed.append(int(a.text.strip().replace('$','')) # will append to the list

这应该有所帮助。