How to use vbs to realize bookfind to obtain the title and author of the book through the ISBN serial number
This article mainly shows you "how to use vbs to achieve bookfind through the ISBN serial number to get the title of the book and the author", the content is easy to understand, clear, hope to help you solve the doubt, the following let the editor lead you to study and learn "how to use vbs to achieve bookfind through the ISBN serial number to get the title of the book and the author" this article.
Core code:
The copy code is as follows:
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
How to use it:
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.
The above is all the content of the article "how to use vbs to achieve bookfind to get the title and author of a book through ISBN serial number". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!