Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use vbs to realize bookfind to obtain the title and author of the book through the ISBN serial number

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report