javarike 发表于 2009-2-26 01:08:11

AuctionID 每到人家点一下就改变的哦,这样够高难度哦,,

rolaka 发表于 2009-2-26 09:58:28

原帖由 rolaka 于 2009-2-25 18:01 发表 http://www.autoitx.com/images/common/back.gif

#include
$oIE = _IECreate ("http://www.swoopo.com/")
$oDoc = _IEDocGetObj($oIE)
MsgBox(0, "", $oDoc.getElementById("counter_index_page_156171").innerhtml)


哪儿取不到了- - 取SPAN的 ...
...支持xmlhttp对象不能使而已 我这个还是可以用 XD

xayle 发表于 2009-2-26 10:07:39

从页面内读取
<script language="javascript">
   
    auction_detail_js(138189, 30, 0, 0, '5a0552fcb540733e0efbfea655deb9a5');
</script>
GET /telebid-us/counter/138189.html?plain=1&val=5a0552fcb540733e0efbfea655deb9a5&lbp=1 HTTP/1.1
剩余时间

GET /telebid-us/counter/138189.html?plain=1&val=5a0552fcb540733e0efbfea655deb9a5&lbp=1 HTTP/1.1
包含出价人

继续分析...

rolaka 发表于 2009-2-26 10:40:44

原帖由 xayle 于 2009-2-26 10:07 发表 http://www.autoitx.com/images/common/back.gif
从页面内读取

   
    auction_detail_js(138189, 30, 0, 0, '5a0552fcb540733e0efbfea655deb9a5');

GET /telebid-us/counter/138189.html?plain=1&val=5a0552fcb540733e0efbfea655deb9a5&lbp=1 HTTP/1. ...
其实...干嘛不插段js进去...直接从内部破坏...

xayle 发表于 2009-2-26 17:00:26

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)
;~ $title = StringReplace(StringReplace($title, "Auctions | Cheap ", ""), " auctions - bid & win on Swoopo", "")
;~ MsgBox(0,0, $title)
        $adj = StringRegExp($guats, "auction_detail_js\((.*)\)", 3)
;~ MsgBox(0,0, $adj)
;~ MsgBox(0,0, StringReplace($adj, "'", ""))
        $adj = StringStripWS(StringReplace($adj, "'", ""), 8)
;~ MsgBox(0,0, $adj)
        $adj = StringSplit($adj, ",")
;~ MsgBox(0,0, $adj)
        $adj = $adj
;~ $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 = "'" Then
                MsgBox(0, 0, "无信息")
                Exit
        EndIf
        $gucvj = StringReplace(StringReplace($gucvj, "_ev_detail('", ""), ");", "")
        $counter = StringSplit($gucvj, "|")
;~ MsgBox(0, $counter, $counter)
        $data = StringSplit($counter, "=")
        If StringInStr($data, "ct") Then
                If StringInStr($data, "-") 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)
;~                 MsgBox(0, 2, $_ct_time)
                EndIf
        EndIf
;~ MsgBox(0, 0, "剩余时间" & $_ct_time)
        $data = StringSplit($counter, "=")
        If StringInStr($data, "cw") Then
                If StringInStr($data, "") Then
                        $winner = "暂无"
;~                 MsgBox(0, 1, $_ct_time)
                Else
                        $winner = $data
;~                 MsgBox(0, 2, $_ct_time)
                EndIf
        EndIf
;~ MsgBox(0, 0, "当前投标者:" & $winner)
        $data = StringSplit($counter, "=")
        If StringInStr($data, "cp") Then
                If StringInStr($data, "") Then
                        $price = "暂无"
;~                 MsgBox(0, 1, $_ct_time)
                Else
                        $price = _Format_Price($data)
;~                 MsgBox(0, 2, $_ct_time)
                EndIf
        EndIf

        GUICtrlSetData($Label4, $price)
        GUICtrlSetData($Label5, $winner)
        GUICtrlSetData($Label6, $_ct_time)

EndFunc   ;==>_getcounter
:face (13):
_basic.au3
Func _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 编辑 ]

rolaka 发表于 2009-2-26 21:24:05


#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Include <Array.au3>
#include <IE.au3>

Local $name, $price, $time

$url = InputBox("", "请输入需要监视的页面", "http://www.swoopo.com/auction/sony-bravia-kdl-37m4000-37-inch-720p-lcd/156737.html")
If @error Then
        Exit
EndIf

;创建ie对象
$oIE = _IECreate($url)
;获取dom对象
$oDoc = _IEDocGetObj($oIE)
;获取名字
$Temps = _IETagNameGetCollection($oIE, "h3")
For $Temp In $Temps
    $name = $Temp.innerhtml
Next
;取得图片url
$Temp = _IEGetObjById($oIE, "prod_main_img")
InetGet($Temp.src, "img.jpg", 1, 0)

#Region ### START Koda GUI section ### Form=
GUICreate("", 421, 416, 192, 124)
GUICtrlCreatePic("img.jpg", 10, 8, 400, 300, BitOR($SS_NOTIFY,$WS_GROUP,$WS_BORDER,$WS_CLIPSIBLINGS))
GUICtrlCreateLabel("商品名:", 8, 320, 75, 23)
GUICtrlSetFont(-1, 14, 800, 0, "宋体")
GUICtrlCreateLabel("价格:", 8, 384, 55, 23)
GUICtrlSetFont(-1, 14, 800, 0, "宋体")
GUICtrlCreateLabel("倒计时:", 8, 352, 75, 23)
GUICtrlSetFont(-1, 14, 800, 0, "宋体")
$time = GUICtrlCreateLabel("--:--:--", 90, 352, 320, 23)
GUICtrlSetFont(-1, 14, 800, 0, "宋体")
$price = GUICtrlCreateLabel("", 66, 384, 344, 23)
GUICtrlSetFont(-1, 14, 800, 0, "宋体")
GUICtrlCreateLabel($name, 90, 320, 322, 24)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        If GUIGetMsg() == $GUI_EVENT_CLOSE Then
                Exit
        EndIf
        Sleep(100)
        ;获取时间
        $Temp = _IEGetObjById($oIE, "countertime")
        GUICtrlSetData($time, $Temp.innertext)
        ;获取价格
        $Temp = _IEGetObjById($oIE, "a_current_price")
        GUICtrlSetData($price, $Temp.innertext)
WEnd



我也来凑凑热闹- -

[ 本帖最后由 rolaka 于 2009-2-27 09:43 编辑 ]

javarike 发表于 2009-2-28 18:04:34

非常感谢 rolaka,我爱rolaka!!

又学习了新的知识了!我爱AU3!

sxd 发表于 2009-2-28 23:02:30

这种网站是真的么..汗 楼主要是买到了便宜货 记得回来晒晒

javarike 发表于 2009-3-1 02:57:14

原帖由 sxd 于 2009-2-28 23:02 发表 http://www.autoitx.com/images/common/back.gif
这种网站是真的么..汗 楼主要是买到了便宜货 记得回来晒晒

哦,是真的,但是现在关闭了.我得了一个SD卡,要350多才 拍到的,不合算啊..呵呵.我的同事想放1K进去....这个跟赌博一样,劝大家莫冒险.想玩的就要跟赌博一样,要有钱进去没得回的的心态....

:face (32):

sxd 发表于 2009-3-1 03:28:41

汗 还以为能买到好东西 ...

tf卡....1g 包快递 14块 汗啊

javarike 发表于 2009-3-2 09:26:51

原帖由 sxd 于 2009-3-1 03:28 发表 http://www.autoitx.com/images/common/back.gif
汗 还以为能买到好东西 ...

tf卡....1g 包快递 14块 汗啊

是啊,我还以为可以买到好东西,但是这个网站明显有枪手在搞鬼,笔记本相机等好东西根本拍不了!

所以我还是将网站去了,免得害了大家...我帮人家做的东西.早已经不玩了,早放手早超生..哈``

veve 发表于 2017-3-4 18:14:15

没有钱只能留言

veve 发表于 2017-3-4 18:16:22

没有钱只能留言
页: 1 [2]
查看完整版本: (谢谢rolaka!!)读取AJAX已经解决!网页动态数据成功!