devil3380 发表于 2011-2-22 10:10:28

正则表达式的应用

本帖最后由 devil3380 于 2011-2-22 10:12 编辑

#NoTrayIcon
#Region ;**** 参数创建于 AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=d:\autoit3\Aut2Exe\Icons\TLB.ico
#AutoIt3Wrapper_Outfile=NOD32UPDATEID.exe
#AutoIt3Wrapper_Res_Comment=获取NOD 32 最新升级ID by:tong QQ:4042709
#AutoIt3Wrapper_Res_Description=OEM 信息修改工具
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_LegalCopyright=Copyright ? 1997-2009 Sitong, Inc.
#AutoIt3Wrapper_Run_Au3check=n

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("在线取得NOD最新升级ID by:tong QQ:4042709", 415, 239, 372, 370)
$Edit1 = GUICtrlCreateEdit("", 8, 8, 250, 230)
GUICtrlSetData(-1, "")
$Label1 = GUICtrlCreateLabel("在线取得NOD最新升级ID", 272, 40, 135, 17)
$Label2 = GUICtrlCreateLabel("BY:TONG QQ:4042709", 280, 64, 116, 17)
$Label3 = GUICtrlCreateLabel("2008-03-03", 336, 88, 65, 17)
$Button1 = GUICtrlCreateButton("取得NOD升级ID", 288, 152, 123, 33, 0)
$Button2 = GUICtrlCreateButton("退出程序", 288, 192, 123, 33, 0)
GUISetState(@SW_SHOW)
#EndRegion ### START Koda GUI section ### Form=

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
   Case $GUI_EVENT_CLOSE
    Exit
   Case $Button1
    qd()
   Case $Button2
    exit
EndSwitch
WEnd

Func qd()
ww()
$file = FileOpen("D:\test1.txt", 0)

;Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

$line = FileRead($file)
$nOffset = 1
While 1

$array = StringRegExp($line, '(assord: \w{10})|(serame: \w{2,3}.\w{7,8})', 1, $nOffset)
If @error = 0 Then
$nOffset = @extended
Else
ExitLoop
EndIf
for $i = 0 to UBound($array) - 1
   ;msgbox(0, "RegExp Test with Option 1 - " & $i, $array[$i])
   GUICtrlSetData ($Edit1, $array[$i] & @CRLF,"edit")
Next

Wend
FileClose($file)
EndFunc

Func ww()
$down = "http://www.taomail.com.cn"
$new_file ="D:\test1.txt"
downwww($down,$new_file)
$file = FileOpen("D:\test1.txt", 0)

;Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

$line = FileReadLine($file,57)
$nOffset = 1
While 1

$array = StringRegExp($line, '(article.asp.id=\w{2})', 1, $nOffset)
If @error = 0 Then
$nOffset = @extended
Else
ExitLoop
EndIf
for $i = 0 to UBound($array) - 1
   ;msgbox(0, "RegExp Test with Option 1 - " & $i, $array[$i])
   $down = "http://www.taomail.com.cn/" & $array[$i]   ;取得链接
   $new_file = "D:\test.txt"
   downwww($down,$new_file) ;下载ID页面
   ;msgbox(0, "R",$down)
Next

Wend
FileClose($file)
EndFunc

Func downwww($down,$new_file)
InetGet($down, $new_file, 1, 1)

While @InetGetActive
   TrayTip("下载中", $new_file & "已下载 = " & @InetGetBytesRead & "字节", 10, 16)
   Sleep(250)
Wend

TrayTip("下载完成", $new_file & "已下载完成。", 10, 16)
EndFunc已经解决了,自己弄错了
页: [1]
查看完整版本: 正则表达式的应用