windows计划任务自动生成静态首页
来源:互联网 发布:域名怎么绑定esc服务器 编辑:程序博客网 时间:2024/04/29 13:31
indexplan.vbs: 脚本程序,调用ie组建执行生成首页的程序这里强调的是必须打开ie,要用到ie的组建,遨游好像不行。然后把这个脚本程序添加到windows计划任务里,设置好执行时间间隔,看你首页跟新的快慢了,自己把握。
Dim IESet IE = CreateObject("InternetExplorer.Application")ie.navigate("http://localhost:80/createindex.asp")-这里在服务器换成你的域名指向你的生成文件ie.visible=0Set IE = NothingASP版本:
Server.ScriptTimeOut=9999999 Function BytesToBstr(body,Cset)'防止乱码函数dim objstreamset objstream = Server.CreateObject("adodb.stream")objstream.Type = 1objstream.Mode =3objstream.Openobjstream.Write bodyobjstream.Position = 0objstream.Type = 2objstream.Charset = CsetBytesToBstr = objstream.ReadTextobjstream.Closeset objstream = NothingEnd FunctionFunction GetHTTPPage(Url)'获取Html代码函数err.clearOn Error Resume Nextdim http set http=Server.createobject("Microsoft.XMLHTTP") Http.open "GET",url,false Http.send()if Http.readystate<>4 thenexit function end if GetHTTPPage = bytesToBSTR(Http.responseBody,"GB2312")set http = NothingIf Err Then response.write err.description Response.Write "<br><br><p align='center'><font color='red'><b>无法抓取本页面信息!!!</b></font></p>"End IfEnd functionUrl="http://www.xxxxx.com/index.asp"strHtml=GetHTTPPage(Url)filename=server.mappath("index.html")if strHtml<>"" then'读取到首页源代码 set fso = Server.CreateObject("scripting.FileSystemObject")if fso.FileExists(filename) then '静态首页存在,删除旧页面 fso.DeleteFile filename set fout = fso.CreateTextFile(filename,true,False)'重新生成 fout.write strHtml fout.close set fout=nothing set fso=nothing else set fout = fso.CreateTextFile(filename,true,False) fout.write strHtml fout.close set fout=nothing set fso=nothing end if end ifASP.NET版本:
using System;using System.Data;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Text;using System.Text.RegularExpressions;using System.IO;using System.Net;public partial class CreatIndex : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { //index.html页面存在先删除旧页面,然后生成新页面 if (File.Exists(@"E:/product/index.html")) { File.Delete(@"E:/product/index.html"); string URL = "http://www.xxxx.com"; string Content = GetHtmlContent(URL); CreateIndex(Content); } //index.html页面不存在直接生成 else { string URL = "http://www.xxxx.com"; string Content = GetHtmlContent(URL); CreateIndex(Content); } } //生成index.html页面 protected void CreateIndex(string con) { string IndexPath = @"E:/product/index.html"; //StreamWriter sr = File.CreateText(@"E:/product/index.html"); StreamWriter sr = new StreamWriter(IndexPath, true, System.Text.Encoding.GetEncoding("GB2312")); Response.Write("生成Index.html文件成功。生成时间:" + System.DateTime.Now); sr.WriteLine(con); sr.Close(); } //读取网页源代码 private string GetHtmlContent(string Url) { string strHtmlContent = ""; try { //声明一个HttpWebRequest请求 HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url); //连接超时时间 request.Timeout = 500000; request.Headers.Set("Pragma", "no-cache"); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream streamHtmlCode = response.GetResponseStream(); Encoding encoding = Encoding.GetEncoding("GB2312"); StreamReader streamReader = new StreamReader(streamHtmlCode, encoding); strHtmlContent = streamReader.ReadToEnd(); } catch { Response.Write("对不起出错了"); } return strHtmlContent; }}
- windows计划任务自动生成静态首页
- windows计划任务自动备份
- 自动备份,批处理,windows计划任务
- WINDOWS计划任务设置MYSQL自动备份
- DEDECMS首页自动生成静态文件index.html
- Windows 7任务计划帮你自动运行程序
- 用ntbackup加Windows任务计划来实现自动备份
- Windows任务计划实现自动执行ArcGIS相关功能
- MysQL windows 下自动备份,同时加入计划任务脚本
- 使用Windows的任务计划程序 自动运行脚本设置
- 配置mysql数据库自动备份:windows任务计划
- winfrom,wpf程序自动启动(windows计划任务方式)
- windows下设置计划任务自动执行PHP脚本
- Mysql计划任务自动定时备份数据库方法-for windows
- Windows使用计划任务自动Git同步代码
- Windows计划任务
- Windows 任务计划 Scheduler
- windows 计划任务
- 字符串过滤
- 编写Linux系统下Daemon程序的方法步骤
- 失落的古国
- s60 第二版 按键iscancode 检测小程序 源码
- SQLSERVER高可用性镜像的困惑
- windows计划任务自动生成静态首页
- 一些好用的VIM插件(转)
- 网络推广的三个重点方向
- silverlight beta2 wcf双向通讯学习记录
- eclipse下alt+/快捷键方式失效的解决
- 打发时光的102个网站
- VIM+TagList( 使用VIM开发软件项目 - 使用tag文件和taglist插件)
- dwr动态载入小结
- WordPress资源