Jump to content

How to get countdown timer value from html code?


closedeed
 Share

Recommended Posts

I need to get coundown value from page. After _WinHttpSimpleRequest in $sHTML I have page HTML code.

How from page code get value of timer?

countdown.thumb.png.d7ff80afa7180c0ae8ba

Code of countdown timer div:

<div id="countdown-item1">
    <div class="dash days_dash"> <span class="dash_title">d :</span>
       <div class="digit"><div class="top" style="display: none;">0</div><div class="bottom" style="display: block;">0</div></div>
        <div class="digit"><div class="top" style="display: none;">0</div><div class="bottom" style="display: block;">0</div></div>
     </div>
    <div class="dash hours_dash"> <span class="dash_title">h :</span>
        <div class="digit"><div class="top" style="display: none;">0</div><div class="bottom" style="display: block;">0</div></div>
        <div class="digit"><div class="top" style="display: none;">7</div><div class="bottom" style="display: block;">7</div></div>
    </div>
    <div class="dash minutes_dash"> <span class="dash_title">m :</span>
        <div class="digit"><div class="top" style="display: none;">3</div><div class="bottom" style="display: block;">4</div></div>
        <div class="digit"><div class="top" style="display: none;">9</div><div class="bottom" style="display: block;">0</div></div>
        </div>
    <div class="dash seconds_dash"> <span class="dash_title">s</span>
        <div class="digit"><div class="top" style="display: none;">2</div><div class="bottom" style="display: block;">3</div></div>
        <div class="digit"><div class="top" style="display: block; overflow: hidden; height: 7.23956px; padding-top: 0px; margin-top: 0px; padding-bottom: 0px; margin-bottom: 0px;">1</div><div class="bottom" style="display: block; overflow: hidden; height: 9.34447px;">2</div></div>
    </div>
    <div style="clear:both;"></div>
</div>
Edited by closedeed
Link to comment
Share on other sites

#include <File.au3>
#include <MsgBoxConstants.au3>

Local $Answer;The time value you are looking for
$File = FileOpen(@DesktopDir & "\sample.txt");I saved your html as sample.txt
$Text = FileRead($File);open the text in sample.txt into a variable

For $i=1 to 7
    $x = StringInStr($Text,'<div class="digit">',0);search for html code
    $y = StringTrimLeft($Text,$x + 58);return the digit 58 characters after found html code
    $Text = $y;trim the html in the $text variable so we can get our next instance
    $z = StringLeft($y,1);read the number
    If $i > 1 Then
        $Answer = $Answer & $z;concantenate the found numbers
    Else
        $Answer = $z;set the value of answer when there is no value in $answer
    EndIf
Next

MsgBox(0,0,$Answer)

This should help at lease a little. I cannot see the last seconds digit with what you posted.

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Link to comment
Share on other sites

<div class="digit"><div class="top" style="display: block; overflow: hidden; height: 7.23956px; padding-top: 0px; margin-top: 0px; padding-bottom: 0px; margin-bottom: 0px;">1</div><div class="bottom" style="display: block; overflow: hidden; height: 9.34447px;">2</div></div>
    </div>
    <div style="clear:both;"></div>

here last second (1 - now, 2 - next second). Now I get all digits from html. But I I can't understand how to get all this code from html block <div id="countdown-item1">

I take HTML code from page:

http://www.pandawill.com/auction-product

When " countdown to start "  I need get time and alarm when timer finished. When auction started, then new countdown with text " countdown to end".

Then I need mail and SMS alarm before 10 minutes

 

 

Link to comment
Share on other sites

Try this :

$aRes = StringRegExp($sContent, '(?s)<div id="countdown-item1">.+?none;">(\d)<.+?none;">(\d)<.+?none;">(\d)<.+?none;">(\d)<.+?none;">(\d)<.+?none;">(\d)<.+?none;">(\d)<.+?none;">(\d)<', 3)
    If IsArray($aRes) Then ConsoleWrite($aRes[0] & $aRes[1] & " d :" & $aRes[2] & $aRes[3] & " h :" & $aRes[4] & $aRes[5] & " m :" & $aRes[6] & $aRes[7] & " s" & @CRLF)

 

Link to comment
Share on other sites

jguinch, nothing :(

 

#include <WinHTTP.au3>
#include <Array.au3>

global $hSession = _WinHttpOpen("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0")
global $hConnect = _WinHttpConnect($hSession, "www.pandawill.com")
$sHTML = _WinHttpSimpleRequest($hConnect, "GET", "auction-product", "www.pandawill.com", "")
FileWrite("testPanda 1.html", $sHTML)

ConsoleWrite("start get time" & @CRLF)
$aRes = StringRegExp($sHTML, '(?s)<div id="countdown-item1">.+?none;">(\d)<.+?none;">(\d)<.+?none;">(\d)<.+?none;">(\d)<.+?none;">(\d)<.+?none;">(\d)<.+?none;">(\d)<.+?none;">(\d)<', 3)
    _ArrayDisplay($aRes)
    If IsArray($aRes) Then ConsoleWrite($aRes[0] & $aRes[1] & " d :" & $aRes[2] & $aRes[3] & " h :" & $aRes[4] & $aRes[5] & " m :" & $aRes[6] & $aRes[7] & " s" & @CRLF)
ConsoleWrite("stop get time" & @CRLF)
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hSession)
Exit

 

Link to comment
Share on other sites

ha ha.. problem that in $sHTML all zero 

<div id="countdown-item1">
    <div class="dash days_dash"> <span class="dash_title">d :</span>
        <div class="digit"></div>
        <div class="digit">0</div>
    </div>
    <div class="dash hours_dash"> <span class="dash_title">h :</span>
         <div class="digit">0</div>
        <div class="digit">0</div>
    </div>
    <div class="dash minutes_dash"> <span class="dash_title">m :</span>
        <div class="digit">0</div>
        <div class="digit">0</div>
    </div>
    <div class="dash seconds_dash"> <span class="dash_title">s</span>
        <div class="digit">0</div>
        <div class="digit">0</div>
    </div>
    <div style="clear:both;"></div>
</div>

When this page in browser javascript change digits.

May I sniff time from script?

</script><script type="text/javascript" src="http://pic.pandawill.com/skin/frontend/default/pandawill/js/jquery.lwtCountdown-1.0.js"></script>

 

Edited by closedeed
Link to comment
Share on other sites

I tried this code, without WinHTTP
 

#Include <IE.au3>

$oIE = _IECreate("http://www.pandawill.com/auction-product", 0, 1)

While 1
    $sContent = _IEBodyReadHTML($oIE)
    $aRes = StringRegExp($sContent, '(?s)<div id="countdown-item1">.+?none;">(\d)<.+?none;">(\d)<.+?none;">(\d)<.+?none;">(\d)<.+?none;">(\d)<.+?none;">(\d)<.+?none;">(\d)<.+?none;">(\d)<', 3)
    If IsArray($aRes) Then ConsoleWrite($aRes[0] & $aRes[1] & " d :" & $aRes[2] & $aRes[3] & " h :" & $aRes[4] & $aRes[5] & " m :" & $aRes[6] & $aRes[7] & " s" & @CRLF)
    Sleep(1000)
WEnd

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...