au3 用xmlhttp 读取网页 每秒循环一次的话很卡... 
 
可以把剩余时间读取出来,最后2秒提交数据, 时间差异不应该很大 
 
搞不下去了, 程序太卡了..#include "_basic.au3"
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$aid = "138189"
$url = "http://www.swoopo.com/"
$aut = "auction/" & $aid & ".html"
$csp = "telebid-us/counter/" & $aid & ".html?plain=1"
$val = "&val="
$lbp = "&lbp=1"
$title = ""
$adj = ""
_getauct($url&$aut)
;~ MsgBox(0,0, $adj)
#Region ### START Koda GUI section ### Form=H:\Study\Autoit\autoisiis\Swoopo\swoopo.kxf
$Form1 = GUICreate("Form1", 404, 152, 248, 310)
GUISetFont(10, 400, 0, "Tahoma")
$Label1 = GUICtrlCreateLabel("Zune 120 GB Video MP3 Player (Black)", 10, 8, 260, 20)
$Label2 = GUICtrlCreateLabel("价格:", 10, 40, 39, 20)
$Label3 = GUICtrlCreateLabel("投标人:", 10, 76, 54, 20)
$Label4 = GUICtrlCreateLabel("00000", 78, 38, 39, 20)
GUICtrlSetColor(-1, 0x008000)
$Label5 = GUICtrlCreateLabel("00000", 78, 74, 39, 20)
$Label6 = GUICtrlCreateLabel("--:--:--", 40, 110, 60, 20)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
;~         AdlibEnable("_getcounter($url&$csp&$val&$adj)", 1000)
_getcounter($url&$csp&$val&$adj)
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        AdlibDisable()
                        Exit
        EndSwitch
WEnd
Func _getauct($url)
;~         $guats = _xmlhttp_get($url, "")
        $guats = InetGet($url, "sx.txt", 1)
        $guats = FileRead("sx.txt")
;~ $title = StringRegExp($guats, "<title>(.*)</title>", 3)
;~ MsgBox(0,0, $title[0])
;~ $title = StringReplace(StringReplace($title[0], "Auctions | Cheap ", ""), " auctions - bid & win on Swoopo", "")
;~ MsgBox(0,0, $title)
        $adj = StringRegExp($guats, "auction_detail_js\((.*)\)", 3)
;~ MsgBox(0,0, $adj[0])
;~ MsgBox(0,0, StringReplace($adj[0], "'", ""))
        $adj = StringStripWS(StringReplace($adj[0], "'", ""), 8)
;~ MsgBox(0,0, $adj)
        $adj = StringSplit($adj, ",")
;~ MsgBox(0,0, $adj[5])
        $adj = $adj[5]
;~ $gucvj = _xmlhttp_get($url&$csp&$val&+"5a0552fcb540733e0efbfea655deb9a5","")
;~ $gucvl = _xmlhttp_get($url&$csp&$val&+"5a0552fcb540733e0efbfea655deb9a5"&$lbp,"")
;~ FileWrite("swoopo"&$aid&".txt", $guats)
;~ FileWrite("swoopo"&$aid&"c.txt", $gucvj)
;~ FileWrite("swoopo"&$aid&"cl.txt", $gucvl)
;~ MsgBox(0,0, _xmlhttp_get($url&$val&+"5a0552fcb540733e0efbfea655deb9a5",""))
;~ MsgBox(0,0, $guats)
;~ MsgBox(0,0, $gucvj)
;~ MsgBox(0,0, $gucvl)
;~ if IsArray ($adj)=0 then msgbox (0,"","匹配失败")
EndFunc   ;==>_getauct
Func _getcounter($url)
;~         $gucvj = _xmlhttp_get($url, "")
        $gucvj = InetGet($url, "sx.txt", 1)
        $gucvj = FileRead("sx.txt")
        $cccheck = StringSplit($gucvj, ",")
        If $cccheck[1] = "'" Then
                MsgBox(0, 0, "无信息")
                Exit
        EndIf
        $gucvj = StringReplace(StringReplace($gucvj, "_ev_detail('", ""), ");", "")
        $counter = StringSplit($gucvj, "|")
;~ MsgBox(0, $counter[0], $counter[1])
        $data = StringSplit($counter[1], "=")
        If StringInStr($data[1], "ct") Then
                If StringInStr($data[2], "-") Then
                        $_ct_time = "--:--:--"
;~                 MsgBox(0, 1, $_ct_time)
                ElseIf $data == 0 Then
                        $_ct_time = "已经结束"
;~                 MsgBox(0, 2, $_ct_time)
                Else
                        $_ct_time = _Calc_Time($data[2])
;~                 MsgBox(0, 2, $_ct_time)
                EndIf
        EndIf
;~ MsgBox(0, 0, "剩余时间" & $_ct_time)
        $data = StringSplit($counter[3], "=")
        If StringInStr($data[1], "cw") Then
                If StringInStr($data[2], "") Then
                        $winner = "暂无"
;~                 MsgBox(0, 1, $_ct_time)
                Else
                        $winner = $data[2]
;~                 MsgBox(0, 2, $_ct_time)
                EndIf
        EndIf
;~ MsgBox(0, 0, "当前投标者:" & $winner)
        $data = StringSplit($counter[4], "=")
        If StringInStr($data[1], "cp") Then
                If StringInStr($data[2], "") Then
                        $price = "暂无"
;~                 MsgBox(0, 1, $_ct_time)
                Else
                        $price = _Format_Price($data[2])
;~                 MsgBox(0, 2, $_ct_time)
                EndIf
        EndIf
        GUICtrlSetData($Label4, $price)
        GUICtrlSetData($Label5, $winner)
        GUICtrlSetData($Label6, $_ct_time)
EndFunc   ;==>_getcounter
    
_basic.au3Func _Calc_Time($diff)
        If $diff > 0 Then
                $hours = Floor($diff / 3600)
                $minutes = Floor(($diff / 3600 - $hours) * 60)
                $seconds = Round(((($diff / 3600 - $hours) * 60) - $minutes) * 60)
        Else
                $hours = 0
                $minutes = 0
                $seconds = 0
        EndIf
        If $seconds == 60 Then $seconds = 0
        If $seconds < 10 And $seconds > 0 Then                
                $seconds = '0' & $seconds
        ElseIf $seconds < 0 Then
                $seconds = 0
        EndIf
        If $minutes < 10 And $minutes > 0 Then                
                $minutes = '0' & $minutes
        ElseIf $minutes < 0 Then
                $minutes = 0
        EndIf
        If $hours < 10 And $hours > 0 Then                
                $hours = '0' & $hours
        ElseIf $hours < 0 Then
                $hours = 0
        EndIf
        Return $hours & ":" & $minutes & ":" & $seconds
EndFunc   ;==>_Calc_Time
Func _Format_Price($price)
        $delimiter = "."
        $currency = "$"
        $price_length = StringLen($price)
        If ($price_length == 1) Then
                Return $currency & "0.0" & $price
        ElseIf ($price_length == 2) Then
                Return $currency & "0." & $price
        Else
                $cent = StringRight($price, 2)
                Return $currency & StringLeft($price, $price_length - 2) & $delimiter & $cent
        EndIf
EndFunc   ;==>_Format_Price
  [ 本帖最后由 xayle 于 2009-2-26 17:03 编辑 ] |