#include <IE.au3>
#include<guiconstantsex.au3>
#include<file.au3>
#include<windowsconstants.au3>
GUICreate("IE", 500, 480)
Global $gccal = GUICtrlCreateInput("", 10, 340, 440, 30)
Global $gccal2 = GUICtrlCreateInput("", 10, 380, 440, 30)
Global $gccal3 = GUICtrlCreateInput("", 10, 420, 440, 30)
_IEErrorHandlerRegister()
$oie = _IECreateEmbedded()
Local $obj = GUICtrlCreateObj($oie, 10, 10, 490, 290)
GUISetState()
GUIRegisterMsg($WM_SYSCOMMAND, "wm_syscommand")
Global $url = "http://detail.tmall.com/item.htm?id=13620534478"
test($url)
While 1
Local $msg = GUIGetMsg()
Select
Case $msg = -3
Exit
EndSelect
Sleep(1000)
WEnd
Func test($url)
Local $html = _IENavigate($oie, $url)
_IEAction($oie, "refresh")
_IELoadWait($oie)
Local $html3 = _IEBodyReadHTML($oie)
$hw = FileOpen(@DesktopDir & "\1.txt", 10)
FileWrite($hw, "")
FileWriteLine(@DesktopDir & "\1.txt", $html3)
Local $strarray
_FileReadToArray(@DesktopDir & "\1.txt", $strarray)
FileClose($hw)
FileDelete(@DesktopDir & "\1.txt")
GUICtrlSetData($gccal, "")
For $i = 238 To $strarray[0]
Local $strmid = StringRegExp($strarray[$i], "举报此商品", 3)
If Not @error Then; 名称
Local $Strname = StringRegExp($strarray[$i - 1], 'target=_blank>([^\/]+?)</A>', 3) ;获取名称
If Not @error Then
GUICtrlSetData($gccal, "商品名称:" & $Strname[0])
EndIf
EndIf
Local $Sreg = StringRegExp($strarray[$i], 'Price>(\d+\.\d+)</STRONG>.*什么是专柜价', 3) ;获取价格
If Not @error Then
GUICtrlSetData($gccal2, "价格:" & $Sreg[0] & " 元")
EndIf
Local $Srtmo = StringRegExp($strarray[$i], '.*月销量.+Num>(\d+)</EM>', 3) ;获取销量
If Not @error Then
GUICtrlSetData($gccal3, "月销量:" & $Srtmo[0] & " 件")
ExitLoop
EndIf
Next
EndFunc ;==>test
Func wm_syscommand($hWnd, $sMsg, $sWParam, $slParam)
Switch $sWParam
Case 61536
Exit
EndSwitch
EndFunc ;==>wm_syscommand
|