Check if you have updated scripting tools in the specified website page

xiaoxiao2021-03-06  54

Copyright Notice: You can reprint anything, you must indicate the original source and author information in hyperlink when reprint.

Recently, I have seen the novel online, and there are not many novels, I have read it. After a relatively good look, some novels were in the state of being treated. Every day, I have to go to a few novel sites to see if there is an update, very cumbersome, anger, write a VB Script script, special Go to the specified page to see if there is an update. Put here, archive.

Note:

1. If you want to run the script, you need XML 3.0 support because an XMLHTTP object is used. XML Download Address: Microsoft XML Parser 3.0 SP 4.

2. ResponseBody returned from the XMLHTTP object is binary data, and Chinese cannot read directly, and it needs to be converted. In the VB environment, you can use the strConv function directly. This is done here to implement: Call the ADO.STREM class, set the character set type Charset, write the stream, and then press the specified type character to read.

3. General Chinese page will use CHARSET: GB2312 or UTF-8 in two ways. For example, the latter used by 9CBS, when the character flow is converted, you also need to call GetResponseHeader, get encoding information from the HTTP header. General UTF-8 will be explicitly specified, GB2312 is the default.

'********************************************************** ****** 'script name: checkfav.vbs' Writer ????: fog' 'Check The Special URL'S Content' and compare with stored content before '' 'V1.1 ?? 2004-09-13' 1. The resulting mirror file no longer contains only site names, but a full path to a given URL, '??? Avoid the same image of multiple different path files in the same site. '' V1.0 ?? 2004-09-10 '1. Read the page of the specified URL address and the mirror file is generated in the real estate. '2. Support the specified multiple URL addresses, and read the URL address array. '3. Increase read HTTP returns and get the character set judgment (GB / UTF-8). '' ********************************************************* ******** const c_ori = 0const c_new = 1

DIM? URL (7), IURL (0) = "http://blog.9cbs.net/fogdragon/" URL (1) = "http://www.jinyuan.org/" URL (2) = "http : //read.hjsm.net/book/4216/html/contents.html "URL (3) =" http://read.hjsm.net/book/574/html/contents.html "URL (4) = "http://read.hjsm.net/book/505/html/contents.html"url(5)="http://read.hjsm.net/book/298/html/contents.html"url(6 ) = "http://read.hjsm.net/book/7033/html/contents.html"

For i = 0 to Ubound (URL)? IF LEN (URL (i))> 0 Then ?? strnewname = CreateName (URL (i), c_new) ?? StructinaMe = CreateName (URL (i), c_ori) ?? intReady = Readyforget (URL (I), Strnewname, StructiName) ?? STRTITLE = GetCurrentPage (URL (I), STRNEWNAME) ?? strshow = startle & "(" & URL (i) & ")"? WScript.echo strshow

?? IF intReady = 1 THEN ??? INTDIFFBYTE = CompareURL (strnewname, Structoriname) ??? strshow = "Update:" & INTDIFFBYTE & "BYTE" ?? Else ??? strshow = "CREATE ORIGIN MIRROR SUCCESS." ?? END IF ???? wscript.echo strshow ?? wscript.echo ""? End ifnext

'Check for obtaining the last record, and if there is, in addition ori the file name, as a backup, future comparison Function ReadyForGet (DescURL, NewName, OriName) Dim strOriName, strNewName, objFSOSet objFSO = CreateObject ( "Scripting.FileSystemObject")

If Objfso.fileexists (newname) = TRUE THEN? Objfso.copyfile newname, oriname, true? Readyforget = 1ELSE? Readyforget = 0nd iness function

'Obtain the specified URL of the page content Function GetCurrentPage (DescURL, NewName) Dim objHTTP, strCodebase, objFSO, strFileName, objLogFileSet objHTTP = CreateObject ( "MSXML2.XMLHTTP") Call objHTTP.Open ( "GET", DescURL, FALSE) objHTTP.SendstrCodebase = getCodeBase (objHTTP.getResponseHeader ( "Content-Type")) strIndex = BytesToBstr (objHTTP.ResponseBody, strCodebase) Set objHTTP = NothingGetCurrentPage = GetBlock (LCase (strIndex), "")

Set objFSO = CreateObject ( "Scripting.FileSystemObject") Set objLogFile = objFSO.CreateTextFile (NewName, True) objLogFile.Write strIndexobjLogFile.CloseSet objFSO = NothingEnd Function

Function CompareURL (NewName, OriName) Dim objFSO, fNew, fOriSet objFSO = CreateObject ( "Scripting.FileSystemObject") Set fNew = objFSO.GetFile (NewName) Set fOri = objFSO.GetFile (OriName) CompareURL = fNew.Size - fOri.SizeEnd Function 'Adodb.Stream binary data using Function BytesToBstr (strBody, CodeBase) Dim objStreamset objStream = CreateObject ( "Adodb.Stream") objStream.Type = 1objStream.Mode = 3objStream.OpenobjStream.Write strBodyobjStream.Position = 0objStream.Type = 2objStream .Charset = codebasebytestobstr = objstream.readtext objstream.closeset objstream = Nothingend Function

'Get the website domain name Function geturlsite (Strurl) getURLsite = getBlock (Strull, "http: //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////>

'The character set identifier in the http return value Function getCodeBase (strhead) getCodeBase = getBlock (strhead, "charSet =", "") if len (getcodebase) = 0 dam getcodebase = "GB2312" End Function

'Creating a file name Function CreateName (strsource, INTTYPE) DIM SS = strsources = Replace (Replace (s, "http: //", ""), "/", ".")

Select Case INTTYPECASE C_NEW CREANAME = S & ".htm" Case C_ori Createname = S & ".ori.htm" End SelectEnd Function

'Get two characters in the middle of the specified feature string (strsource, strdesstart, strdend) ??? DIM ISTART, IEND, S ??? iStart = IEND, S ??? ISTART = IEND ??? if iStart = 0 THEN ?? ?? GetBlock = "" ??? Else ??????? if len (strdend)> 0 THEN ???????? Iend = IEND = INSTR (iStart Len (StrDesStart), strsource, strdend) ?? ?????? iStart = iStart Len (strdesstart) ???????? getBlock = MID (strsource, istart, IEND - istart) ??????? Else ???????? GetBlock = Right (strsource, len (strsource) - iStart - len (strdesstart) 1) ??????? end if ??? End IFEND FUNCTION test run output result:

D: / Work / Checkfav> Checkfav.vbsmicrosoft (R) Windows Script Host Version 5.6 Copyright (C) Microsoft Corporation 1996-2001. all rights reserved.

Dragon ride (http://blog.9cbs.net/fogdragon/)Update:1097byte

Xinhua Lianjinyuan - Owner's online home (http://www.jinyuan.org/ )Update:219byte

"China Fairy Magic" - Dragon Massan - Magical Books (http://read.hjsm.net/book/4216/html/contents.html )Update:0byte

Xiaofei Legend - Xuan Yu - Magic Sword (http://read.hjsm.net/book/574/html/contents.html )Update:0byte

Zhu Xian - Xiao Ding - Magic Sword (http://read.hjsm.net/book/505/html/contents.html )Update:0byte

Mercenary World - Say Masters - Magical Books (http://read.hjsm.net/book/298/html/contents.html )Update:0byte

The revenge of big magic tutor - reading the people - Magic Sword (http://read.hjsm.net/book/7033/html/contents.html )Update:0byte

?

Reference:

MSXML 4.0 SDK Documentation

Microsoft XML Parser 3.0 SP4 SDK

转载请注明原文地址:https://www.9cbs.com/read-118244.html

New Post(0)