如何使用beauthulsoup Python检索拍卖时间

2024-04-29 11:15:40 发布

您现在位置:Python中文网/ 问答频道 /正文

我想在下一个拍卖网站上取回计时器来制作狙击手:

http://www.vakantieveilingen.nl/veiling-van-de-dag.html

我需要获得拍卖时间,我可以在:

<div class="auction-time"> 
  <span class="h-init h-time-tick 
        ng-valid ng-binding ng-dirty" 
        ng-hide="popup.laughingSecondPrice > 0"
        ng-model="auction.time" ng-bind-html="auction.time.left|timeLeftFormatForBiedWidget"
        h-model-name="expires"><strong>03</strong><i>:</i><strong>31</strong>
  </span> 
  <span ng-show="popup.laughingSecondPrice > 0" class="ng-hide">Gesloten</span>
</div>

我找不到一个正确的方法来做这件事。谁能给我指路吗?在


Tags: divmodeltime网站htmlngclass计时器
1条回答
网友
1楼 · 发布于 2024-04-29 11:15:40

您只需要一个CSS selector来使用auction-time类在div元素中获取{}元素:

auction_time_span = soup.select('.auction-time span.h-time-tick')[0]
print(auction_time_span.get_text())

^{} function然后返回包含的字符串值。在

演示:

^{pr2}$

在浏览器中,通过Javascript代码将HTML中的时间和日期转换为相对时间。在

相关问题 更多 >