python - Extracting a tag value in Beautiful Soup
问题描述
I am parsing a html document using beautiful soup in python.
I came across a tag like this
div class="_3auQ3N">\u20b9<!-- -->1,990</div>
\u20bp represents currency symbol and 1,990 is the price.
I want to know how can I extract these values into two different Strings (or values)?
解决方案
>>> soup = BeautifulSoup('<div class="_3auQ3N">\u20b9<!-- -->1,990</div>', 'lxml')
>>> list(soup.div.strings)
['₹', '1,990']
推荐阅读
- vba - 我的用户文件夹或网络驱动器中的 Excel VBA 文件“另存为”问题
- c++ - cpp 生成一个 .lib 并在另一个项目中使用它
- c++ - 从数组中提取对数
- javascript - 如何将 materializejs 组件与流星一起使用
- outlook - Outlook 不通过 iCal 发送对活动邀请的答复
- segmentation-fault - 特定行中的 C 分段错误
- android-fragments - 活动在片段上出现的权限对话框中被破坏
- kubernetes - 为什么 envoy sidecar 可以控制我的流量?
- git - 如何正确修复我的 git 工作流程
- spring - Kubernetes:Spring Cloud Data Flow Server 的服务帐户权限问题