|
本帖最后由 leehomv 于 2010-1-14 13:09 编辑
在下面这段代码中,怎么才能实现在网址和关键字的后面追加一段网页代码呢??
比如实现访问的地址为:http://www.sogou.com/sogou?p=400 ... e1e0f2b23a8056-5200
代码如下:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Winapi.au3>
#include <IE.au3>
#Include <File.au3>
HotKeySet("{f3}","ieshow1")
HotKeySet("{f4}","winshow1")
while 1
$sFilePath = FileOpenDialog( "请选择随即关键词txt文件", @ScriptDir, "(*.txt)", 3)
If @error Then
MsgBox(0,"","你没有选择任何文件,程序将退出。")
Exit
EndIf
ExitLoop
WEnd
$uur=""
$hanghao = _FileCountLines($sFilePath)
$oIE = _IECreate ("about:blank",1,0,0,-1);打开网页,可以隐藏IE
_IEPropertySet ($oIE, "toolbar", 0) ;隐藏toolbar
_IEPropertySet ($oIE, "width", 400) ;设置ie宽800像素
_IEPropertySet ($oIE, "height", 400) ;设置ie高600像素
_IEPropertySet ($oIE, "resizable", 0) ;设置ie不可以调整大小
$suiji = 0
$xunhuan = 0
$chaoshi = 0
$dangqian = 0
$tongji = 0
$line = "请输入关键词"
opt("guiOneventMode",1)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("小刷一下", 257, 195, 192, 150)
GUISetOnEvent($gui_event_close,"Close_Click",$Form1)
$Label0 = GUICtrlCreateLabel("URL:", 8, 10, 28, 17)
$Combo1 = GUICtrlCreateCombo("", 38, 8, 211, 25)
gengxin($uur)
$Group1 = GUICtrlCreateGroup("配置", 8, 33, 241, 137)
$Button1 = GUICtrlCreateButton("开始", 144, 49, 97, 89, $WS_GROUP)
GUICtrlSetOnEvent(-1,"RUNSTART")
$Label1 = GUICtrlCreateLabel("当前:"&$dangqian&"\统计:"&$tongji&"\词库:"&$hanghao, 8, 177, 200, 17)
GUICtrlSetColor(-1, 0x716F64)
$Checkbox1 = GUICtrlCreateCheckbox("显示IE窗口[F3]", 16, 49, 100, 17)
GUICtrlSetOnEvent(-1,"ieshow")
$Checkbox2 = GUICtrlCreateCheckbox("随机使用词库", 16, 97, 89, 17)
GUICtrlSetOnEvent(-1,"suiji")
$Checkbox3 = GUICtrlCreateCheckbox("循环使用词库", 16, 121, 97, 17)
$Checkbox4 = GUICtrlCreateCheckbox("设置页面超时", 16, 145, 94, 17)
GUICtrlSetOnEvent(-1,"chaoshi")
$Input1 = GUICtrlCreateInput("1000", 112, 145, 49, 21)
GUICtrlSetState ($Input1,$GUI_DISABLE)
$Label2 = GUICtrlCreateLabel("毫秒", 168, 148, 28, 17)
$Checkbox5 = GUICtrlCreateCheckbox("隐藏当前窗体[F4]", 16, 73, 113, 17)
GUICtrlSetOnEvent(-1,"winshow")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Func gengxin(ByRef $uur)
$URLL=IniReadSection("URL.INI","URL")
If @error Then
$sData = "1=http://www.sogou.com/sogou?query=" & @LF & "2=http://www.baidu.com/s?wd=" & @LF & "3=http://www.google.cn/search?hl=zh-CN&q="& @LF & "4=http://www.gougou.com/search?search="
IniWriteSection("URL.INI","URL", $sData)
Else
if $URLL[0][0] >1 Then
For $i = 1 To $URLL[0][0]-1
$uur=$uur&$URLL[$i][1]&"|"
Next
$uur=$uur&$URLL[$URLL[0][0]][1]
Else
$uur=$uur&$URLL[$URLL[0][0]][1]
EndIf
EndIf
GUICtrlSetData ($Combo1,$uur,$URLL[1][1])
EndFunc
Func RUNSTART()
if GUICtrlRead ($Button1) = "开始" then
GUICtrlSetData ($Button1,"暂停")
Else
GUICtrlSetData ($Button1,"开始")
EndIf
EndFunc
Func Close_Click()
_IEQuit ($oIE)
Exit
EndFunc
Func ieshow1()
if BitAnd(GUICtrlRead($Checkbox1),$GUI_CHECKED) Then
GUICtrlSetState ( $Checkbox1, $GUI_UNCHECKED )
Else
GUICtrlSetState ( $Checkbox1, $GUI_CHECKED )
EndIf
ieshow()
EndFunc
Func winshow1()
if BitAnd(GUICtrlRead($Checkbox5),$GUI_CHECKED) Then
GUICtrlSetState ( $Checkbox5, $GUI_UNCHECKED )
Else
GUICtrlSetState ( $Checkbox5, $GUI_CHECKED )
EndIf
winshow()
EndFunc
Func ieshow()
if BitAnd(GUICtrlRead($Checkbox1),$GUI_CHECKED) Then
_IEAction ($oIE,"visible")
Else
_IEAction ($oIE,"invisible")
EndIf
EndFunc
Func winshow()
if BitAnd(GUICtrlRead($Checkbox5),$GUI_CHECKED) Then
GUISetState(@SW_HIDE,$Form1)
Else
GUISetState(@SW_SHOW,$Form1)
EndIf
EndFunc
Func bianliang(ByRef $suiji,ByRef $xunhuan,ByRef $chaoshi)
if BitAnd(GUICtrlRead($Checkbox2),$GUI_CHECKED)Then
$suiji = 1
$xunhuan = 1
Else
$suiji = 0
EndIf
if BitAnd(GUICtrlRead($Checkbox3),$GUI_CHECKED)Then
$xunhuan = 1
Else
$xunhuan = 0
EndIf
if BitAnd(GUICtrlRead($Checkbox4),$GUI_CHECKED)Then
$chaoshi = 1
Else
$chaoshi = 0
EndIf
EndFunc
Func suiji()
if BitAnd(GUICtrlRead($Checkbox2),$GUI_CHECKED)Then
GUICtrlSetState ( $Checkbox3, $GUI_CHECKED )
GUICtrlSetState ( $Checkbox3,$GUI_DISABLE)
Else
GUICtrlSetState ( $Checkbox3,$GUI_ENABLE)
EndIf
EndFunc
Func chaoshi()
if BitAnd(GUICtrlRead($Checkbox4),$GUI_CHECKED)Then
GUICtrlSetState ( $Input1,$GUI_ENABLE)
Else
GUICtrlSetState ( $Input1,$GUI_DISABLE)
EndIf
EndFunc
While 1
bianliang($suiji,$xunhuan,$chaoshi)
if GUICtrlRead ($Button1) = "开始" then
Sleep(0)
Else
guanjian($suiji,$hanghao,$dangqian,$xunhuan,$sFilePath,$line)
if GUICtrlRead ($Button1) = "暂停" then
_IENavigate ($oIE, GUICtrlRead($Combo1)&$line, 1 )
$tongji = $tongji+1
EndIf
GUICtrlSetData ($Label1,"当前:"&$dangqian&"\统计:"&$tongji&"\词库:"&$hanghao)
yanshi()
EndIf
WEnd
Func yanshi()
if $chaoshi = 1 Then
sleep(GUICtrlRead($Input1))
Else
_IELoadWait ($oIE)
EndIf
EndFunc
Func guanjian($suiji,$hanghao,ByRef $dangqian,$xunhuan,$sFilePath,ByRef $line)
if $suiji = 1 Then
$dangqian = Random (1, $hanghao, 1)
Else
if $dangqian < $hanghao then
$dangqian = $dangqian +1
Else
if $xunhuan = 1 Then
$dangqian = 1
Else
wancheng($hanghao)
$dangqian = 0
EndIf
EndIf
EndIf
$file = FileOpen($sFilePath, 0)
$line = FileReadLine($file,$dangqian)
FileClose($file)
EndFunc
Func wancheng($hanghao)
MsgBox(4096,"任务完成","关键词库共有"&$hanghao&"词条,现已读取到最后一个。")
GUICtrlSetData ($Button1,"开始")
EndFunc |
|