【发布时间】:2018-04-18 21:10:59
【问题描述】:
这是给出输出的 HTML 文本 - £0.03。
我想通过 xpath 找到这个值并将输出打印到 pycharm 控制台。
<div class="pnl runner-info-elem below-runner-info" ng-if="ctrl.vm.events.shouldShowPnl(runner)" ng-class="{'below-runner-info': ctrl.vm.data.displayRaceCardInfo}">
<!---->
<mv-runner-pnl ng-repeat="(type, pnl) in ctrl.vm.data.pnl[runner.key] track by type" type="actual" values="pnl.values" separator="comma" formatter="::pnl.formatter">
<!-- PnL -->
<div class="runner-elem-pnl actual-pnl">
<span class="prefix"></span>
<span class="pnl-value-container">
<span class="pnl-value negative">-£0.03</span>
</span>
<span class="pnl-value-container hidden"><span>
我尝试了以下方法:
driver.find_element_by_xpath('//*[@id="main-wrapper"]/div/div[3]/div/div[2]/div/div[1]/div[3]/div/div[1]/div/bf-main-market/bf-main-marketview/div/div[2]/bf-marketview-runners-list[2]/div/div/div/table/tbody/tr[1]/td[1]/div/div[3]').get_attribute(pnl.value)
print(pnl.value)
我的结果是:
:NameError: name 'pnl' is not defined
这甚至可能吗?如果不是通过xpath,那么通过任何其他方式? 正如我所说,我对此完全陌生,并试图从 YouTube 教程中学习。
【问题讨论】:
标签: python html selenium pycharm