1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| #include <Array.au3> if FileExists(@TempDir & "\autoitrss.xml")Then FileDelete(@TempDir & "\autoitrss.xml") InetGet("http://www.mind-pioneer.com/replace_pioneer_examples.xml", @TempDir & "\autoitrss.xml");rss订阅地址 Else InetGet("http://www.mind-pioneer.com/replace_pioneer_examples.xml", @TempDir & "\autoitrss.xml") EndIf $file = FileOpen(@TempDir & "\autoitrss.xml",0)
If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf
$chars = FileRead($file) Global $arrayt = StringRegExp($chars, '<title>(.+?)<\/title>',3) Global $arrayl = StringRegExp($chars, '<link>(.+?)<\/link>',3) Global $arrayp = StringRegExp($chars, '<pubDate>(.+?)<\/pubDate>',3) _ArrayDelete($arrayl, 0) _ArrayDelete($arrayt, 0) FileClose($file)
;_ArrayDisplay($arrayt) ;_ArrayDisplay($arrayl) ;_ArrayDisplay($arrayp) If FileExists("config.ini") Then Local $pubDate = IniRead("config.ini", "Date", "latest", 0) If $pubDate == $arrayp[0] Then MsgBox(0, "Done", "is the latest!") Exit EndIf For $i = 1 to UBound($arrayp)-1 If $arrayp[$i] = $pubDate Then _load($i) Next MsgBox(0,"警告", "没有匹配的日期,请手动更新") Else MsgBox(48, "Error", "config.ini could not be opened!") Exit EndIf
Func _load($i) For $j = 0 to $i-1 Local $TempDown=InetGet($arrayl[$j],@ScriptDir & "\data\Update\" & StringRegExpReplace($arrayl[$j], 'http.*\/', ''),1) ;定义变量$TempDown接受InetGet()函数返回的句柄 Next IniWrite("config.ini","Date","latest", $arrayp[0]) MsgBox(0,"Done","更新完毕,共下载" & $i & "个文件") Exit EndFunc
|