bookfind 通過(guò)ISBN序號(hào)獲取圖書(shū)連接的書(shū)名與作者的vbs代碼
更新時(shí)間:2011年12月26日 00:02:20 作者:
bookfind 通過(guò)ISBN序號(hào)獲取圖書(shū)連接的書(shū)名與作者的vbs代碼,類(lèi)似小偷程序,通過(guò)正則匹配,雖然現(xiàn)在已經(jīng)無(wú)法使用,但代碼不錯(cuò),原理都有
核心代碼:
If WScript.Arguments.UnNamed.Count <> 1 Then Syntax
If WScript.Arguments.Named.Count > 1 Then Syntax
blnTd = False
If WScript.Arguments.Named.Count = 1 Then
If UCase( WScript.Arguments.Named( 0 ) ) = "/TD" Then
blnTd = True
Else
Syntax
End If
End If
strISBN = WScript.Arguments.UnNamed( 0 )
strPgTitle = TitleFromHTML( "http://www.amazon.com/gp/product/" & strISBN & "/" )
strPattern = "Amazon.com: (.*): Books: (.*)$"
strTitle = RegExpVal( strPattern, strPgTitle, 0 )
strAuthor = RegExpVal( strPattern, strPgTitle, 1 )
If blnTd Then
strMsg = strISBN & vbTab & strTitle & vbTab & strAuthor & vbCrLf
Else
strMsg = vbCrLf & "Title : " & strTitle _
& vbCrLf & "Author : " & strAuthor _
& vbCrLf & "ISBN : " & strISBN
End If
WScript.Echo strMsg
Function RegExpVal( strPattern, strString, idx )
On Error Resume Next
Dim regEx, Match, Matches, RetStr
Set regEx = New RegExp
regEx.Pattern = strPattern
regEx.IgnoreCase = True
regEx.Global = True
Set Matches = regEx.Execute( strString )
RegExpVal = Matches( 0 ).SubMatches( idx )
End Function
Function TitleFromHTML( strURL )
Set ie = CreateObject( "InternetExplorer.Application" )
ie.Navigate strURL
Do Until ie.ReadyState = 4
WScript.Sleep 10
Loop
TitleFromHTML = ie.Document.Title
ie.Quit
End Function
Sub Syntax
strMsg = strMsg & vbCrLf & "BookFind.vbs, Version 1.11" & vbCrLf _
& "Display book title and author name for the specified ISBN number." & vbCrLf & vbCrLf _
& "Usage: CSCRIPT //NOLOGO BOOKFIND.VBS isbn [ /TD ]" & vbCrLf & vbCrLf _
& "Where: ""isbn"" is the ISBN (or ASIN) of the book to search for" & vbCrLf _
& " /TD changes the output format to tab delimited" & vbCrLf & vbCrLf _
& "Note: This script uses Amazon's web site to look up author and title." & vbCrLf _
& " To be precise, the data is extracted from the title of the page" & vbCrLf _
& " with URL http://www.amazon.com/gp/product/ followed by the ISBN." & vbCrLf _
& " That means this script will fail when Amazon changes the URLs." & vbCrLf & vbCrLf _
& "Written by Rob van der Woude" & vbCrLf _
& "http://www.robvanderwoude.com"
Wscript.Echo( strMsg )
Wscript.Quit( 1 )
End Sub
使用方法:
CSCRIPT //NOLOGO BOOKFIND.VBS isbn [ /TD ]
Where: "isbn" is the ISBN (or ASIN) of the book to search for
/TD changes the output format to tab delimited
Note: This script uses Amazon's web site to look up author and title.
To be precise, the data is extracted from the title of the page
with URL http://www.amazon.com/gp/product/ followed by the ISBN.
That means this script will fail when Amazon changes the URLs.
復(fù)制代碼 代碼如下:
If WScript.Arguments.UnNamed.Count <> 1 Then Syntax
If WScript.Arguments.Named.Count > 1 Then Syntax
blnTd = False
If WScript.Arguments.Named.Count = 1 Then
If UCase( WScript.Arguments.Named( 0 ) ) = "/TD" Then
blnTd = True
Else
Syntax
End If
End If
strISBN = WScript.Arguments.UnNamed( 0 )
strPgTitle = TitleFromHTML( "http://www.amazon.com/gp/product/" & strISBN & "/" )
strPattern = "Amazon.com: (.*): Books: (.*)$"
strTitle = RegExpVal( strPattern, strPgTitle, 0 )
strAuthor = RegExpVal( strPattern, strPgTitle, 1 )
If blnTd Then
strMsg = strISBN & vbTab & strTitle & vbTab & strAuthor & vbCrLf
Else
strMsg = vbCrLf & "Title : " & strTitle _
& vbCrLf & "Author : " & strAuthor _
& vbCrLf & "ISBN : " & strISBN
End If
WScript.Echo strMsg
Function RegExpVal( strPattern, strString, idx )
On Error Resume Next
Dim regEx, Match, Matches, RetStr
Set regEx = New RegExp
regEx.Pattern = strPattern
regEx.IgnoreCase = True
regEx.Global = True
Set Matches = regEx.Execute( strString )
RegExpVal = Matches( 0 ).SubMatches( idx )
End Function
Function TitleFromHTML( strURL )
Set ie = CreateObject( "InternetExplorer.Application" )
ie.Navigate strURL
Do Until ie.ReadyState = 4
WScript.Sleep 10
Loop
TitleFromHTML = ie.Document.Title
ie.Quit
End Function
Sub Syntax
strMsg = strMsg & vbCrLf & "BookFind.vbs, Version 1.11" & vbCrLf _
& "Display book title and author name for the specified ISBN number." & vbCrLf & vbCrLf _
& "Usage: CSCRIPT //NOLOGO BOOKFIND.VBS isbn [ /TD ]" & vbCrLf & vbCrLf _
& "Where: ""isbn"" is the ISBN (or ASIN) of the book to search for" & vbCrLf _
& " /TD changes the output format to tab delimited" & vbCrLf & vbCrLf _
& "Note: This script uses Amazon's web site to look up author and title." & vbCrLf _
& " To be precise, the data is extracted from the title of the page" & vbCrLf _
& " with URL http://www.amazon.com/gp/product/ followed by the ISBN." & vbCrLf _
& " That means this script will fail when Amazon changes the URLs." & vbCrLf & vbCrLf _
& "Written by Rob van der Woude" & vbCrLf _
& "http://www.robvanderwoude.com"
Wscript.Echo( strMsg )
Wscript.Quit( 1 )
End Sub
使用方法:
CSCRIPT //NOLOGO BOOKFIND.VBS isbn [ /TD ]
Where: "isbn" is the ISBN (or ASIN) of the book to search for
/TD changes the output format to tab delimited
Note: This script uses Amazon's web site to look up author and title.
To be precise, the data is extracted from the title of the page
with URL http://www.amazon.com/gp/product/ followed by the ISBN.
That means this script will fail when Amazon changes the URLs.
您可能感興趣的文章:
- javascript字符串與數(shù)組轉(zhuǎn)換匯總
- Javascript進(jìn)制轉(zhuǎn)換實(shí)例分析
- Javascript實(shí)現(xiàn)顏色rgb與16進(jìn)制轉(zhuǎn)換的方法
- JavaScript轉(zhuǎn)換二進(jìn)制編碼為ASCII碼的方法
- JavaScript將字符串轉(zhuǎn)換為整數(shù)的方法
- php根據(jù)isbn書(shū)號(hào)查詢(xún)amazon網(wǎng)站上的圖書(shū)信息的示例
- PHP校驗(yàn)ISBN碼的函數(shù)代碼
- JavaScript實(shí)現(xiàn)將UPC轉(zhuǎn)換成ISBN的方法
相關(guān)文章
MSScriptControl.ScriptControl組件的用法實(shí)例
這篇文章主要介紹了MSScriptControl.ScriptControl組件的用法實(shí)例,需要的朋友可以參考下2014-08-08
math.vbs 自然數(shù)n的n次方的的和或積的級(jí)數(shù)
通項(xiàng)為自然數(shù)n的n次方的的和或積的級(jí)數(shù),求和或積的表達(dá)式。2009-09-09
使用腳本調(diào)用系統(tǒng)的關(guān)機(jī)對(duì)話框?qū)崿F(xiàn)代碼
以前有介紹如何使用命令行調(diào)用系統(tǒng)的關(guān)機(jī)對(duì)話框rundll32.exe shell32.dll #60,但是,上述方法會(huì)存在一問(wèn)題,XP下無(wú)法正常使用該方法進(jìn)行關(guān)機(jī)2012-05-05
基于邏輯運(yùn)算的簡(jiǎn)單權(quán)限系統(tǒng)(原理,設(shè)計(jì),實(shí)現(xiàn)) VBS 版
基于邏輯運(yùn)算的簡(jiǎn)單權(quán)限系統(tǒng)(原理,設(shè)計(jì),實(shí)現(xiàn)) VBS 版...2007-03-03
VBS教程:VBScript 語(yǔ)句-Set 語(yǔ)句
VBS教程:VBScript 語(yǔ)句-Set 語(yǔ)句...2006-11-11
自定義vbs腳本實(shí)現(xiàn)開(kāi)機(jī)后延時(shí)啟動(dòng)指定程序的方法
這篇文章主要介紹了自定義vbs腳本實(shí)現(xiàn)開(kāi)機(jī)后延時(shí)啟動(dòng)指定程序的方法,本文以延遲啟動(dòng)金山毒霸為例,需要的朋友可以參考下2014-09-09

