小偷,采集程序常用函数
(编辑:jimmy 日期: 2024/11/26 浏览:3 次 )
<script language="javascript" runat="server">
//连接数据库
function connOpen(DataBaseConnectStr){
var conn = Server.CreateObject("ADODB.Connection");
conn.Open(DataBaseConnectStr);
return conn;
}
//利用AdoDb.Stream对象来读取指定格式的文本文件
function readFromTextFile(FileUrl,CharSet){
var str;
var stm = 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;
return str;
}
//利用AdoDb.Stream对象来写入指定格式的文本文件
function writeToTextFile(FileUrl,Str,CharSet){
var stm = 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判断文件是否存在
function isFileExist(FileUrl){
var FSO = Server.CreateObject("Scripting.FileSystemObject")
if(FSO.FileExists(Server.MapPath(FileUrl))){
return true;
}else{
return false;
}
}
//利用fso写文件
function CateFile(files,fbody){
var fs = Server.CreateObject("Scripting.FileSystemObject");
var a = fs.CreateTextFile(Server.mappath(files));
a.Write(fbody);
a.close();
}
//获取目标页面源代码
function getHTTPPage(url){
var Http= Server.CreateObject("Microsoft.XMLHTTP");
Http.open("GET",url,false);
Http.send();
if (Http.readystate!==4){return false;}
return(BytesToBstr(Http.responseBody,"GB2312"));
}
//编码
function BytesToBstr(body,Cset){
var objstream = 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();
}
//获取完整连接地址
function GetCompleteUrl(sources_url,get_url){
if(get_url.indexOf("http://")!=-1)return get_url;
var completeUrl="";
var sources_url_arr = sources_url.split("/");
var get_url_arr = get_url.split("../");
for(var i=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];
return completeUrl;
}
</script>
//连接数据库
function connOpen(DataBaseConnectStr){
var conn = Server.CreateObject("ADODB.Connection");
conn.Open(DataBaseConnectStr);
return conn;
}
//利用AdoDb.Stream对象来读取指定格式的文本文件
function readFromTextFile(FileUrl,CharSet){
var str;
var stm = 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;
return str;
}
//利用AdoDb.Stream对象来写入指定格式的文本文件
function writeToTextFile(FileUrl,Str,CharSet){
var stm = 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判断文件是否存在
function isFileExist(FileUrl){
var FSO = Server.CreateObject("Scripting.FileSystemObject")
if(FSO.FileExists(Server.MapPath(FileUrl))){
return true;
}else{
return false;
}
}
//利用fso写文件
function CateFile(files,fbody){
var fs = Server.CreateObject("Scripting.FileSystemObject");
var a = fs.CreateTextFile(Server.mappath(files));
a.Write(fbody);
a.close();
}
//获取目标页面源代码
function getHTTPPage(url){
var Http= Server.CreateObject("Microsoft.XMLHTTP");
Http.open("GET",url,false);
Http.send();
if (Http.readystate!==4){return false;}
return(BytesToBstr(Http.responseBody,"GB2312"));
}
//编码
function BytesToBstr(body,Cset){
var objstream = 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();
}
//获取完整连接地址
function GetCompleteUrl(sources_url,get_url){
if(get_url.indexOf("http://")!=-1)return get_url;
var completeUrl="";
var sources_url_arr = sources_url.split("/");
var get_url_arr = get_url.split("../");
for(var i=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];
return completeUrl;
}
</script>
下一篇:一搜图片搜索小偷