第1页共6页本文格式为Word版下载后可任意编辑和复制javascript服务端脚本scriptlanguage="javascript"runat="server"//连接数据库functionconnOpen(DataBaseConnectStr){varconn=Server.CreateObject("ADODB.Connection");conn.Open(DataBaseConnectStr);returnconn;}//利用AdoDb.Stream对象来读取指定格式的文本文件functionreadFromTextFile(FileUrl,CharSet){varstr;varstm=Server.CreateObject("adodb.stream");stm.Type=2;stm.Mode=3;stm.Charset=CharSet;第2页共6页本文格式为Word版下载后可任意编辑和复制stm.open;stm.LoadFromFile(Server.MapPath(FileUrl));str=stm.ReadTextstm.close;returnstr;}//利用AdoDb.Stream对象来写入指定格式的文本文件functionwriteToTextFile(FileUrl,Str,CharSet){varstm=Server.CreateObject("adodb.stream");stm.Type=2;stm.Mode=3;stm.Charset=CharSet;stm.open;stm.WriteText(Str);第3页共6页本文格式为Word版下载后可任意编辑和复制stm.SaveToFile(Server.MapPath(FileUrl),2);stm.flush;stm.close;}//利用fso推断文件是否存在functionisFileExist(FileUrl){varFSO=Server.CreateObject("Scripting.FileSystemObject")if(FSO.FileExists(Server.MapPath(FileUrl))){returntrue;}else{returnfalse;}}//利用fso写文件第4页共6页本文格式为Word版下载后可任意编辑和复制functionCateFile(files,fbody){varfs=Server.CreateObject("Scripting.FileSystemObject");vara=fs.CreateTextFile(Server.mappath(files));a.Write(fbody);a.close();}//猎取目标页面源代码functiongetHTTPPage(url){varHttp=Server.CreateObject("Microsoft.XMLHTTP");Http.open("GET",url,false);Http.send();if(Http.readystate!==4){returnfalse;}return(BytesToBstr(Http.responseBody,"GB2312"));}第5页共6页本文格式为Word版下载后可任意编辑和复制//编码functionBytesToBstr(body,Cset){varobjstream=Server.CreateObject("adodb.stream");objstream.Type=1;objstream.Mode=3;objstream.Open();objstream.Write=body;objstream.Position=0;objstream.Type=2;objstream.Charset=Cset;return(objstream.ReadText);objstream.Close();}//猎取完整连接地址第6页共6页本文格式为Word版下载后可任意编辑和复制functionGetCompleteUrl(sources_url,get_url){if(get_url.indexOf("get_url;varcompleteUrl="";varsources_url_arr=sources_url.split("/");varget_url_arr=get_url.split("../");for(vari=0;isources_url_arr.length-get_url_arr.length;i++){completeUrl+=sources_url_arr[i]+"/";}completeUrl+=get_url_arr[get_url_arr.length-1];returncompleteUrl;}/script