小偷,采集程序常用函数

2018-09-06 10:40

阅读:599

  <scriptlanguage=javascriptrunat=server>
//连接数据库
functionconnOpen(DataBaseConnectStr){
conn.Open(DataBaseConnectStr);
returnconn;
}
//利用AdoDb.Stream对象来读取指定格式的文本文件
functionreadFromTextFile(FileUrl,CharSet){
varstr;
varstm=Server.CreateObject(adodb.stream);
stm.Type=2;
stm.Mode=3;
stm.Charset=CharSet;
stm.open;
stm.LoadFromFile(Server.MapPath(FileUrl));
str=stm.ReadText
stm.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);
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写文件
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));
}
//编码
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();
}
//获取完整连接地址
functionGetCompleteUrl(sources_url,get_url){
varcompleteUrl=;
varsources_url_arr=sources_url.split(/);
varget_url_arr=get_url.split(../);
for(vari=0;i<sources_url_arr.length-get_url_arr.length;i++){
completeUrl+=sources_url_arr[i]+/;
}
completeUrl+=get_url_arr[get_url_arr.length-1];
returncompleteUrl;
}
</script>


评论


亲,登录后才可以留言!