Search code examples
apixpathxquerytelegram

How to use published_date - Method in Telegram's instant view API?


I am trying to setup an Instant View for a website. Everything's working fine, except the published_date aspect. As I found it, it needs an div-container (or similar) with date information. Than it has to be transformed to unixtime timestamp via "@datetime(-2): xpath_query". but how do I continue?

i.e:

I tried:

<div class="Date">19.05.2017</div>
$date: //div[has-class("Date")]
@datetime(-2): $date
published_date: $@

but this has no effect on the date. What am I doing wrong? The telegram manuel is too brief.


Solution

  • I don't know how to deal with it, so I use this dirty work for my template

    $date: //div[has-class("Date")]/text()
    @debug  # 19.05.2017
    @replace("(\\d\\d)\\.(\\d\\d)\\.(\\d{4})", "$3/$2/$1"): $date
    @debug  # 2017/05/19
    published_date: $@
    @debug  # 1495141200 (2017/05/19)
    

    It convert 19.05.2017 to 2017/05/19, and then published_date can parse it.