Thieves, collection procedures commonly used functions _ Thieves/Collection

Source: Internet
Author: User
<script language= "javascript" runat= "Server" >
Connecting to a database
function Connopen (DATABASECONNECTSTR) {
var conn = Server.CreateObject ("ADODB.") Connection ");
Return conn;
Use the object to read text files in a specified format
function Readfromtextfile (fileurl,charset) {
var str;
var stm = Server.CreateObject ("");
Stm. Type = 2;
Stm. Mode = 3;
Stm. Charset=charset;;
Stm. LoadFromFile (Server.MapPath (FILEURL));
str = stm. ReadText
return str;
Use the object to write to a text file in the specified format
function Writetotextfile (fileurl,str,charset) {
var stm = Server.CreateObject ("");
Stm. Type = 2;
Stm. Mode = 3;
Stm. Charset = Charset;;
Stm. SaveToFile (Server.MapPath (FILEURL), 2);
Use FSO to determine whether a file exists
function Isfileexist (FILEURL) {
var FSO = Server.CreateObject ("Scripting.FileSystemObject")
if (FSO). FileExists (Server.MapPath (FILEURL))) {
return true;
return false;
Use FSO to write files
function Catefile (files,fbody) {
var fs = Server.CreateObject ("Scripting.FileSystemObject");
var a = fs. CreateTextFile (Server.MapPath (files));
A.write (Fbody);
A.close ();
Get target page source code
function Gethttppage (URL) {
var http= server.createobject ("Microsoft.XMLHTTP"); ("Get", url,false);
Http.send ();
if (http.readystate!==4) {return false;}
Return (BYTESTOBSTR (http.responsebody, "GB2312"));
function Bytestobstr (body,cset) {
var objstream = Server.CreateObject ("");
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 ();
Get full Connection Address
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;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.