python - AngularJS - Selenium - 如何获取选项标签值
问题描述
仅出于学术目的,我试图获取列表的所有选项值。我尝试使用通过 ID 查找来使用硒和美丽的汤,但我得到了错误。任何建议将不胜感激。
<div class="ec-combo-box__wrapper" data-ng-class="{ 'mds-container--dark-gray': false }"> <!-- ngIf: labels.contains('caption') -->
<select data-ng-model="ngModel" data-ng-disabled="parameters.disabled" id="ec-screener-filters-securities-combo-box[branding-company-id]" class="ec-combo-box__select ng-not-empty select2-hidden-accessible ng-dirty ng-valid-parse" data-ng-class="{ 'mds-form--error': addErrorClass() }" data-ng-options="parameters.runtimeSelectLabel && labels.contains(listItem[settings.get('valueField')]) ?
labels.get(listItem[settings.get('valueField')]) : listItem[settings.get('valueField')]
for listItem in model.listItems track by listItem[settings.get('keyField')]" aria-invalid="false" tabindex="-1" aria-hidden="true"><!-- ngIf: placeholder --><option data-ng-if="placeholder" value="" class="ng-binding ng-scope">Select a Fund Provider</option><!-- end ngIf: placeholder --><option label="All" value="null" selected="selected">All</option><option label="7IM" value="BN00000BPZ">7IM</option><option label="Abacus"
我想获取所有选项标签 vale 的列表,例如“7IM”
解决方案
用于find_all
查找所有option
标签,然后label
像这样访问属性:
soup = BeautifulSoup(html, 'html.parser')
options = []
for item in soup.find_all('option'):
options += [item['label']]
推荐阅读
- linux - linux下nvcc报错:包含向量,设备代码不支持
- amazon-web-services - 需要不同数量的基于 Docker 的隔离应用程序,这些应用程序具有来自 AWS 的不同公共 IP
- android - android中的改造响应返回空值
- python - 从 Pandas 中的字符串中删除子字符串
- php - 使用 Laravel Passport 设置 API - 为什么我会收到未经授权的错误?
- c++ - 如何在不同的头文件中实现成员函数?
- angular - 有什么方法可以混合 Angular Material mat-sidenav 的“推送”和“过度”模式?
- sympy - 在 sympy 中区分用户功能?
- c# - 如何检查数据库中是否有任何新数据或使用 EF Core 使用新数据更新 DbSet
- html - Visual Studio 代码搜索/替换中的正则表达式以更改具有任何结构的 url