山东那个儿童医院好:ASP 程序自动运行问题
来源:百度文库 编辑:查人人中国名人网 时间:2024/05/10 08:46:36
代码是
<%
Function GetPage(url)
'获得文件内容
dim Retrieval
Set Retrieval = CreateObject("Microsoft.XMLHTTP")
With Retrieval
.Open "Get", url, False ', "", ""
.Send
GetPage = BytesToBstr(.ResponseBody)
End With
Set Retrieval = Nothing
End Function
Function BytesToBstr(body)
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = "GB2312"
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
on error resume next
Url="http://www.so360.cn/corporation/trade.asp?sortid=11"'要读取的页面地址
response.write "开始更新首页..."
wstr = GetPage(Url)
'response.write(wstr)
Set fs=Server.CreateObject("Scripting.FileSystemObject")
'if not MyFile.FolderExists(server.MapPath("/html/")) then
'MyFile.CreateFolder(server.MapPath("/html/"))'
'end if
'要存放的页面地址
dizhi=server.MapPath("index.htm")
If (fs.FileExists(dizhi)) Then
fs.DeleteFile(dizhi)
End If
Set CrFi=fs.CreateTextFile(dizhi)
Crfi.Writeline(wstr)
set CrFi=nothing
set fs=nothing
response.write "...<font color=red>更新完成!</font>"
%>
是一个生成静态的程序
我想让它在每天的 3点、8点50分、18点 自动运行
请大家帮个忙
我就20分了
全给了
<%
Function GetPage(url)
'获得文件内容
dim Retrieval
Set Retrieval = CreateObject("Microsoft.XMLHTTP")
With Retrieval
.Open "Get", url, False ', "", ""
.Send
GetPage = BytesToBstr(.ResponseBody)
End With
Set Retrieval = Nothing
End Function
Function BytesToBstr(body)
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = "GB2312"
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
on error resume next
Url="http://www.so360.cn/corporation/trade.asp?sortid=11"'要读取的页面地址
response.write "开始更新首页..."
wstr = GetPage(Url)
'response.write(wstr)
Set fs=Server.CreateObject("Scripting.FileSystemObject")
'if not MyFile.FolderExists(server.MapPath("/html/")) then
'MyFile.CreateFolder(server.MapPath("/html/"))'
'end if
'要存放的页面地址
dizhi=server.MapPath("index.htm")
If (fs.FileExists(dizhi)) Then
fs.DeleteFile(dizhi)
End If
Set CrFi=fs.CreateTextFile(dizhi)
Crfi.Writeline(wstr)
set CrFi=nothing
set fs=nothing
response.write "...<font color=red>更新完成!</font>"
%>
是一个生成静态的程序
我想让它在每天的 3点、8点50分、18点 自动运行
请大家帮个忙
我就20分了
全给了
这要用到计划任务,首先假定你这个程序的地址为“http://1.0.0.8/a.asp”,那么你编辑如下内容:
Dim IE
Set IE = CreateObject("InternetExplorer.Application")
ie.navigate("http://1.0.0.8/a.asp")
ie.visible=1
Set IE = Nothing
存储成一个vbs后缀的文件,比如test.vbs。
在windows的管理工具——服务中启动“计划任务”服务。
在控制面板的“任务计划”中,双击“添加任务计划”。
点“下一步”。
点“浏览”,找到并选择你保存的VBS文件。
选择“每天”,点“下一步”。
点“下一步”。
输入你当前用户的登陆密码,点“下一步”。
点“完成”。
在任务计划中找到你新建的计划,双击它。
在“计划”中点“高级”。
选中“显示多项计划”。
点“删除”,再点“新建”。
将“开始时间”改为3:00,再点“新建”。
将“开始时间”改为8:50,再点“新建”。
将“开始时间”改为18:00,点“确定”。
计划配置完了,最后在你定时执行的程序的最后加上如下关闭窗口的代码:
<script language=javascript>
window.opener='';
window.close();
</script>
这样就完成你的要求了……不知道你看明白了没?
楼上说的方法都正确。
但是根据楼主的需要,最好的解决办法是写一个windows service的程序。楼主需要学习一下windows service编程
加一个定时器
一个IE客户端一直打开着,定时自动刷新