【发布时间】:2019-03-03 21:22:37
【问题描述】:
所以我查看了堆栈溢出,但似乎找不到我的问题的答案。如何在 标签之后获取文本、特定文本?
这是我的代码:
product_review_container = container.findAll("span",{"class":"search_review_summary"})
for product_review in product_review_container:
prr = product_review.get('data-tooltip-html')
print(prr)
这是输出:
Very Positive<br>86% of the 1,013 user reviews for this game are positive.
我希望在这个字符串中只有 86% 和 1,013。所以只有数字。但是它不是 int,所以我不知道该怎么做。
这里是文本的来源:
[<span class="search_review_summary positive" data-tooltip-html="Very Positive<br>86% of the 1,013 user reviews for this game are positive.">
</span>]
这是我获取信息的链接:https://store.steampowered.com/search/?specials=1&page=1
谢谢!
【问题讨论】:
-
你可以使用正则表达式
标签: python beautifulsoup tags