网络记录器,一个自动搜索指定地址并保存的程序
2010年03月05日
'一个老程序,希望对你有用
'依赖文件:
'D:\UrlList.txt"
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, fin,fout
Dim WshShell
dim ThisLline
Dim Poscomma
set WshShell=WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Set fin=fso.opentextfile("D:\webstock\UrlList.txt",forreading,0)
while fin.AtEndOfStream True
ThisLine=fin.readline
Poscomma=instr(ThisLine,",")
call OpenAUrlAndSaveSource(mid(ThisLine,1,PosComma-1),mid(ThisLine,PosComma+1) & FormatToday() & ".html")
wend
fin.close
set fin=nothing
set fso=nothing
set WshShell=nothing
Wscript.Quit
'Call Example : call OpenAUrlAndSaveSource("http://www.test.com","d:\" & FormatToday() & ".html")
'Parmeter
'Navigate
'FullScreen
'AddressBar
'MenuBar
'ToolBAr
Sub OpenAUrlAndSaveSource(ThisUrl,SavedFileName)
set WshShell = WScript.CreateObject("WScript.Shell")
On Error resume next
Set objIE1=CreateObject("InternetExplorer.application")
objIE1.Visible=true
objIE1.NAvigate ThisUrl
objIE1.FullScreen true
WScript.Sleep 5000
WshShell.SendKeys "%V"
WScript.Sleep 2000
WshShell.SendKeys "C"
WScript.Sleep 2000
'Save notepad
WshShell.SendKeys "%F"
WScript.Sleep 2000
WshShell.SendKeys "A"
WScript.Sleep 2000
WshShell.SendKeys SavedFileName
WScript.Sleep 2000
WshShell.SendKeys "%S"
WScript.Sleep 2000
'Close Notepad
WshShell.SendKeys "%F"
WScript.Sleep 2000
WshShell.SendKeys "X"
WScript.Sleep 5000
objIE1.quit
end sub
Function FormatToday()
strYear = DatePart("yyyy",Date)
' Get current month, add leading zero if necessary
If DatePart("m",Date) < 10 Then
strMonth = 0 & DatePart("m",Date)
Else
strMonth = DatePart("m",Date)
End If
' Get current day, add leading zero if necessary
If DatePart("d",Date) < 10 Then
strDay = 0 & DatePart("d",Date)
Else
strDay = DatePart("d",Date)
End If
' Format output for today
FormatToday = strYear & strMonth & strDay
end function
2010年03月05日
'一个老程序,希望对你有用
'依赖文件:
'D:\UrlList.txt"
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, fin,fout
Dim WshShell
dim ThisLline
Dim Poscomma
set WshShell=WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Set fin=fso.opentextfile("D:\webstock\UrlList.txt",forreading,0)
while fin.AtEndOfStream True
ThisLine=fin.readline
Poscomma=instr(ThisLine,",")
call OpenAUrlAndSaveSource(mid(ThisLine,1,PosComma-1),mid(ThisLine,PosComma+1) & FormatToday() & ".html")
wend
fin.close
set fin=nothing
set fso=nothing
set WshShell=nothing
Wscript.Quit
'Call Example : call OpenAUrlAndSaveSource("http://www.test.com","d:\" & FormatToday() & ".html")
'Parmeter
'Navigate
'FullScreen
'AddressBar
'MenuBar
'ToolBAr
Sub OpenAUrlAndSaveSource(ThisUrl,SavedFileName)
set WshShell = WScript.CreateObject("WScript.Shell")
On Error resume next
Set objIE1=CreateObject("InternetExplorer.application")
objIE1.Visible=true
objIE1.NAvigate ThisUrl
objIE1.FullScreen true
WScript.Sleep 5000
WshShell.SendKeys "%V"
WScript.Sleep 2000
WshShell.SendKeys "C"
WScript.Sleep 2000
'Save notepad
WshShell.SendKeys "%F"
WScript.Sleep 2000
WshShell.SendKeys "A"
WScript.Sleep 2000
WshShell.SendKeys SavedFileName
WScript.Sleep 2000
WshShell.SendKeys "%S"
WScript.Sleep 2000
'Close Notepad
WshShell.SendKeys "%F"
WScript.Sleep 2000
WshShell.SendKeys "X"
WScript.Sleep 5000
objIE1.quit
end sub
Function FormatToday()
strYear = DatePart("yyyy",Date)
' Get current month, add leading zero if necessary
If DatePart("m",Date) < 10 Then
strMonth = 0 & DatePart("m",Date)
Else
strMonth = DatePart("m",Date)
End If
' Get current day, add leading zero if necessary
If DatePart("d",Date) < 10 Then
strDay = 0 & DatePart("d",Date)
Else
strDay = DatePart("d",Date)
End If
' Format output for today
FormatToday = strYear & strMonth & strDay
end function