How to retrieve Auction-Time with Beautifulsoup Python
Question: I'm trying to retrieve the timer on the next auction site to make a Sniper:

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

I need to get the auction time which i can find in:

    
    
    <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>
    

I can't find a right way to do it. Could anyone show me the way?


Answer: All you need is a [CSS
selector](http://www.crummy.com/software/BeautifulSoup/bs4/doc/#css-selectors)
to grab the `span` element in the `div` element with the `auction-time` class:

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

The [`element.get_text()`
function](http://www.crummy.com/software/BeautifulSoup/bs4/doc/#get-text) then
returns the string value contained.

Demo:

    
    
    >>> import requests
    >>> from bs4 import BeautifulSoup
    >>> response = requests.get('http://www.vakantieveilingen.nl/veiling-van-de-dag.html')
    >>> soup = BeautifulSoup(response.content)
    >>> soup.select('.auction-time span.h-time-tick')[0].get_text()
    u'2015-02-02T22:32:00+01:00'
    

The time and date in the HTML served is converted to a relative time by
Javascript code in the browser.

