【发布时间】:2018-01-17 19:14:27
【问题描述】:
好吧,我可能已经进行了 2 个小时的搜索,我相信我的大脑可能只是油炸了。今天是我和 BeautifulSoup 的第一天(所以请温柔一点)。我正在抓取的网站的源代码格式如下:
<a href="/listing/view" class="price">$100</a>
我觉得自己很愚蠢,因为我在写入文件时得到了整个 a 标签,并且我偷偷怀疑有这么简单的解决方案,但我似乎找不到它。
目前我正在使用以下内容:
soup = BeautifulSoup(page.content, 'html.parser')
prices = soup.find_all(class_="price")
passed.append(prices)
如何仅针对特定标签之间具有匹配类的内容?
【问题讨论】:
标签: python html beautifulsoup screen-scraping