#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include<date.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>
Global $Msg, $hQuery, $aRow
$SQLite_Data_Path = "360.db"
Opt("GUIOnEventMode", 1)
#region ### START Koda GUI section ### Form=C:\Users\changxin\Desktop\study\京东价格\Form1.kxf
$Form1 = GUICreate("京东历史价格工具", 895, 438, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$ListView1 = GUICtrlCreateListView("编号|价格|产品|日期", 0, 0, 745, 321)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 550)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 90)
$Label1 = GUICtrlCreateLabel("产品网址", 16, 344, 52, 17)
$Input1 = GUICtrlCreateInput("", 72, 344, 473, 31)
$Button1 = GUICtrlCreateButton("确定", 592, 344, 97, 49)
GUICtrlSetOnEvent(-1, "Button1Click")
GUISetState(@SW_SHOW)
While 1
Sleep(100)
WEnd
Func Button1Click()
$now = _Now()
$url = GUICtrlRead($Input1)
$oHTTP = ObjCreate("microsoft.xmlhttp")
$oHTTP.open("get", $url, False)
$oHTTP.send()
$source2 = $oHTTP.responsetext
$price = StringRegExp($source2, "我在@京东商城 发现了一个非常不错的商品:(.+),京东价:¥(\d+\.\d+)", 3)
_SQLite_Startup()
_SQLite_Open($SQLite_Data_Path)
_SQLite_Exec(-1, "Insert into TestTable (Chanpin) values ('" & $price[0] & "');")
_SQLite_Exec(-1, "UPDATE TestTable SET Jiage = '" & $price[1] & "' WHERE Chanpin = '" & $price[0] & "';")
_SQLite_Exec(-1, "UPDATE TestTable SET Shijian = '" & $now & "' WHERE Chanpin = '" & $price[0] & "';")
_SQLite_Close()
EndFunc ;==>Button1Click
Func Form1Close()
_SQLite_Open($SQLite_Data_Path)
_SQLite_Query(-1, "SELECT * FROM TestTable ORDER BY Chanpin DESC;", $hQuery)
While _SQLite_FetchData ($hQuery, $aRow) = $SQLITE_OK
GUICtrlCreateListViewItem($aRow & "|" & "2" & "|" & "3" & "|" & "4", $ListView1)
WEnd
_SQLite_Close()
EndFunc ;==>Form1Close