测试链接如下:
测试链接(如有乱码,请修改一下页面编码为“简体中文”)
我想实现:
从此页面中提取开始时间,然后定时,时间到了,就单击下面对应的链接
下面是代码,可能有许多需要修改的地方,麻烦帮忙看看
;#NoTrayIcon
#include <IE.au3>
#include <INet.au3>
#include <Date.au3>
Global $oIE
Global $starttime,$TimeNum,$getmoneylink
Dim $aStartTime,$aRedEnvelpeLinks
$url = "http://liuxingworld.com/wp-content/uploads/2009/test.html"
$oIE = _IECreate($url, "url", 1)
_IELoadWait($oIE)
$surl = _IEPropertyGet($oIE, "locationurl")
ConsoleWrite($surl & @CR)
;$sHTML = _IEBodyReadHTML ($oIE)
$sHTML = _INetGetSource($surl)
; get the start time
$aStartTime = StringRegExp($sHTML, "<li>开始时间 (.*?)</li>", 3)
$aRedEnvelpeLinks = StringRegExp($sHTML, '<li><b> <a href="(.*?)"><font', 3)
$TimeNum = UBound($aStartTime) - 1
ConsoleWrite($TimeNum & @CRLF)
For $i = 0 To UBound($aStartTime) - 1
Dim $starttime ; 开始时间
Dim $link ; 链接URL
$starttime = $aStartTime[$i]
$link = $aRedEnvelpeLinks[$i]
ConsoleWrite($starttime & @CRLF)
ConsoleWrite($link & @CRLF)
Next
; #################################
; 就是这里不明白
; 该放在哪里,怎么做?
;AdlibEnable("checktime")
;While 1
;WEnd
; #################################
Sleep(2000) ;pause 2 seconds
_IEQuit($oIE)
Func checktime()
Local $hour, $min, $sec, $timediff
$timediff = _DateDiff('s', _NowCalc(), $starttime)
ConsoleWrite($starttime & @CRLF)
;如果时间差<=30秒,则执行
If $timediff <= 30 Then
AdlibDisable()
_IEAction($link, "click")
ConsoleWrite($link & "--" & @error & @CRLF)
EndIf
EndFunc ;==>checktime
|