【发布时间】:2019-02-25 21:12:50
【问题描述】:
我对硒完全陌生。对于提出愚蠢或愚蠢的问题,请接受道歉。
我在网站上有以下内容。我感兴趣的是如何使用 selenium + python 获得 data-selectdate 值。获得data-selectdate 值后,我想将其与我感兴趣的日期进行比较。
非常感谢您的帮助。
注意:我没有使用美丽的汤或任何东西。
干杯
<table role="grid" tabindex="0" summary="October 2018">
<thead>
<tr>
<th role="columnheader" id="dayMonday"><abbr title="Monday">Mon</abbr></th>
<th role="columnheader" id="dayTuesday"><abbr title="Tuesday">Tue</abbr></th>
<th role="columnheader" id="dayWednesday"><abbr title="Wednesday">Wed</abbr></th>
<th role="columnheader" id="dayThursday"><abbr title="Thursday">Thur</abbr></th>
<th role="columnheader" id="dayFriday"><abbr title="Friday">Fri</abbr></th>
<th role="columnheader" id="daySaturday"><abbr title="Saturday">Sat</abbr></th>
</tr>
</thead>
<tbody>
<tr>
<td role="gridcell" headers="dayMonday">
<a data-selectdate="2018-10-22T00:00:00+01:00" data-selected="false" id="day22"
class="day-appointments-available">22</a>
</td>
<td role="gridcell" headers="dayTuesday">
<a data-selectdate="2018-10-23T00:00:00+01:00" data-selected="false" id="day23"
class="day-appointments-available">23</a>
</td>
<td role="gridcell" headers="dayWednesday">
<a data-selectdate="2018-10-24T00:00:00+01:00" data-selected="false" id="day24"
class="day-appointments-available">24</a>
</td>
<td role="gridcell" headers="dayThursday">
<a data-selectdate="2018-10-25T00:00:00+01:00" data-selected="false" id="day25"
class="day-appointments-available">25</a>
</td>
<td role="gridcell" headers="dayFriday">
<a data-selectdate="2018-10-26T00:00:00+01:00" data-selected="false" id="day26"
class="day-appointments-available">26</a>
</td>
<td role="gridcell" headers="daySaturday">
<a data-selectdate="2018-10-27T00:00:00+01:00" data-selected="false" id="day27"
class="day-appointments-available">27</a>
</td>
</tr>
</tbody>
</table>
【问题讨论】:
-
你能分享网站的链接吗,因为它看起来像当前的 html 没有显示相关元素
-
不幸的是,该 URL 会动态更新日历。所以我认为它不会帮助我们。除此之外,登录凭据后,URL 会出现三四页。
-
看看 ^ 链接...你会得到
data-selectdate属性,它会返回你想要的字符串。从那里您可以对现有日期等进行字符串比较。
标签: python-2.7 selenium selenium-webdriver webdriver getattribute