国际标准书号 -> bookdata 查找以填充数据库

发布于 2024-08-25 12:00:16 字数 188 浏览 7 评论 0原文

好的,我想为一个小型图书馆建立数据库。

我对数据库的经验有限,并且没有从网络服务器查询的经验。

我想要检索标题、出版商、也许是作者、描述等信息 我能想到的最简单的方法是通过 ISBN 查找它们。

我以前接触过 isbndb.com,但访问它的 API 似乎相当复杂。

我想知道我应该如何去做这件事。

Ok, I wanting to database a small library.

I've only had limited experience with databases, and none with querying from a webserver.

I'm going to want to retrieve information like title, Publisher, maybe author, description
the simplest way I can think of dooing this is looking them up via the ISBN.

I've come across isbndb.com before, but the API for accessing it seems rather complex.

I'm wondering how I should go about doing this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

没有你我更好 2024-09-01 12:00:17

ISBNdb.com API 看起来很简单。以下请求应检索您想要的信息...只需将您的访问密钥替换为“YourKey”,并将 ISBN 替换为“YourISBN”。

https://isbndb.com/api/books.xml?access_key=YourKey&results=texts&index1=isbn&value1=YourISBN 

响应是 XML,其中包含有关您提交的 ISBN 的单本书的信息。

The ISBNdb.com API looks simple. The following request should retrieve the information you want ... just substitute your access key for "YourKey" and the ISBN for "YourISBN".

https://isbndb.com/api/books.xml?access_key=YourKey&results=texts&index1=isbn&value1=YourISBN 

The response is XML which contains information about the single book whose ISBN you submitted.

猫性小仙女 2024-09-01 12:00:17

最近,当我们出于保险目的对图书馆进行索引时,我必须这样做。下面是我一起破解的 vba 类的代码:

Option Compare Database
    dim BookTitle As String
    dim BookTitleLong As String
    dim BookAuthorsText As String
    dim BookPublisherText As String
    dim BookSummary As String
    dim BookNotes As String
    dim accessKey As String

Private Sub Class_Initialize()
    'Your isbnDB access key'
    accessKey = "PUT ACCESSKEY HERE"
End Sub    
Property Get Title() As String
    Title = BookTitle
End Property    
Property Get TitleLong() As String
    TitleLong = BookTitleLong
End Property    
Property Get AuthorsText() As String
    AuthorsText = BookAuthorsText
End Property
Property Get PublisherText() As String
    PublisherText = BookPublisherText
End Property
Property Get Summary() As String
    Summary = BookSummary
End Property
Property Get Notes() As String
    Notes = BookNotes
End Property

Public Function Lookup(isbn As String) As Boolean
    Lookup = False
    Dim xmlhttp
    Set xmlhttp = CreateObject("MSXML2.xmlhttp")
    xmlhttp.Open "GET", "https://isbndb.com/api/books.xml?access_key=" & accessKey & "&results=texts&index1=isbn&value1=" & isbn, False
    xmlhttp.send
    'Debug.Print "Response: " & xmlhttp.responseXML.XML'
    Dim xmldoc
    Set xmldoc = CreateObject("Microsoft.XMLDOM")
    xmldoc.async = False
    'Note: the ResponseXml property parses the server's response, responsetext doesn't
    xmldoc.loadXML (xmlhttp.responseXML.XML)
    If (xmldoc.selectSingleNode("//BookList").getAttribute("total_results") = 0) Then
        MsgBox "Invalid ISBN or not in database"
        Exit Function
    End If
    If (xmldoc.selectSingleNode("//BookList").getAttribute("total_results") > 1) Then
        MsgBox "Caution, got more than one result!"
        Exit Function
    End If
    BookTitle = xmldoc.selectSingleNode("//BookData/Title").Text
    BookTitleLong = xmldoc.selectSingleNode("//BookData/TitleLong").Text
    BookAuthorsText = xmldoc.selectSingleNode("//BookData/AuthorsText").Text
    BookPublisherText = xmldoc.selectSingleNode("//BookData/PublisherText").Text
    BookNotes = xmldoc.selectSingleNode("//BookData/Notes").Text
    BookSummary = xmldoc.selectSingleNode("//BookData/Summary").Text
    Lookup = True
End Function

获取 API 密钥,将上面的代码(使用您的密钥)粘贴到 VBA 编辑器中的新类模块中(插入 -> 类模块)并将该模块命名为“isbn” 。您还需要在 VBA 编辑器中添加对“Microsoft XML”的引用(工具 -> 参考)

您可以在普通的 vba 模块中使用下面的代码片段测试它的工作情况:

Public Function testlookup()
    Dim book
    Set book = New isbn
    book.Lookup ("0007102968")
    Debug.Print book.Title
    Debug.Print book.PublisherText
End Function

然后只需在立即窗口中键入“testlookup”(查看->立即窗口)。您应该看到这样的响应:

The Times book of quotations
[Glasgow] : Times Books : 2000.

isbnDB 可以返回比我在上面的类中收集的数据更多的数据,请在此处阅读 API 参考:http://isbndb.com/docs/api/ 并根据您的需求定制课程。

我发现这篇文章对于解释如何在 access 中使用 xmlhttp 非常有帮助:
http://www.15seconds.com/issue/991125.htm

上的 msdn 页面XML DOM 方法和 XMLHttpRequest 对象也很有用(因为我是新用户,我只能发布两个活动链接,您必须替换下面网址中的点):

msdn microsoft com/en-us/library/ms757828 (v=VS.85).aspx

msdn microsoft com/en-us/library/ms535874(v=vs.85).aspx

I recently had to do exactly this as we indexed our library for insurance purposes. Below is the code of the vba class I hacked together:

Option Compare Database
    dim BookTitle As String
    dim BookTitleLong As String
    dim BookAuthorsText As String
    dim BookPublisherText As String
    dim BookSummary As String
    dim BookNotes As String
    dim accessKey As String

Private Sub Class_Initialize()
    'Your isbnDB access key'
    accessKey = "PUT ACCESSKEY HERE"
End Sub    
Property Get Title() As String
    Title = BookTitle
End Property    
Property Get TitleLong() As String
    TitleLong = BookTitleLong
End Property    
Property Get AuthorsText() As String
    AuthorsText = BookAuthorsText
End Property
Property Get PublisherText() As String
    PublisherText = BookPublisherText
End Property
Property Get Summary() As String
    Summary = BookSummary
End Property
Property Get Notes() As String
    Notes = BookNotes
End Property

Public Function Lookup(isbn As String) As Boolean
    Lookup = False
    Dim xmlhttp
    Set xmlhttp = CreateObject("MSXML2.xmlhttp")
    xmlhttp.Open "GET", "https://isbndb.com/api/books.xml?access_key=" & accessKey & "&results=texts&index1=isbn&value1=" & isbn, False
    xmlhttp.send
    'Debug.Print "Response: " & xmlhttp.responseXML.XML'
    Dim xmldoc
    Set xmldoc = CreateObject("Microsoft.XMLDOM")
    xmldoc.async = False
    'Note: the ResponseXml property parses the server's response, responsetext doesn't
    xmldoc.loadXML (xmlhttp.responseXML.XML)
    If (xmldoc.selectSingleNode("//BookList").getAttribute("total_results") = 0) Then
        MsgBox "Invalid ISBN or not in database"
        Exit Function
    End If
    If (xmldoc.selectSingleNode("//BookList").getAttribute("total_results") > 1) Then
        MsgBox "Caution, got more than one result!"
        Exit Function
    End If
    BookTitle = xmldoc.selectSingleNode("//BookData/Title").Text
    BookTitleLong = xmldoc.selectSingleNode("//BookData/TitleLong").Text
    BookAuthorsText = xmldoc.selectSingleNode("//BookData/AuthorsText").Text
    BookPublisherText = xmldoc.selectSingleNode("//BookData/PublisherText").Text
    BookNotes = xmldoc.selectSingleNode("//BookData/Notes").Text
    BookSummary = xmldoc.selectSingleNode("//BookData/Summary").Text
    Lookup = True
End Function

Get an API key, paste the above code (with your key) into a new class module in the VBA editor (Insert->Class Module) and name the module "isbn". You also need to add a reference to "Microsoft XML" in the VBA editor (Tools->References)

You can test it works with the code snippet below in a normal vba module:

Public Function testlookup()
    Dim book
    Set book = New isbn
    book.Lookup ("0007102968")
    Debug.Print book.Title
    Debug.Print book.PublisherText
End Function

Then just type "testlookup" into the immediate window (View->Immediate Window). You should see a response of:

The Times book of quotations
[Glasgow] : Times Books : 2000.

isbnDB can return more than the data I collect in the above class, read the API reference here: http://isbndb.com/docs/api/ and tailor the class to your needs.

I found this article very helpful in explaining how to use xmlhttp from within access:
http://www.15seconds.com/issue/991125.htm

The msdn pages on XML DOM Methods and XMLHttpRequest Object were also useful (because I'm a new user I can only post two active links, you'll have to replace the dots in the urls below):

msdn microsoft com/en-us/library/ms757828(v=VS.85).aspx

msdn microsoft com/en-us/library/ms535874(v=vs.85).aspx

风轻花落早 2024-09-01 12:00:17

您使用什么语言?您需要一个程序/脚本来呈现一个可以输入 ISBN 的表单,然后该表单将从 isbndb.com 获取数据并填充数据库。我使用过该 API,但已经有一段时间了,而且它非常简单。

What language are you using? You need a program/script to present a form where you can enter the ISBN, which would then get the data from isbndb.com and populate the database. I've used the API a bit, but not for some time, and it's pretty straightforward.

不可一世的女人 2024-09-01 12:00:16

这是一个不完整的答案,但它应该可以帮助您入门(我没有使用 XML 数据作为返回)。

此代码具有基础知识:

  Dim oHttp As Object

  Set oHttp = CreateObject("Microsoft.XMLHTTP")
  oHttp.Open "GET", "https://isbndb.com/api/books.xml?access_key=YourKey&results=texts&index1=isbn&value1=YourISBN", False
  oHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
  oHttp.Send vbNullString
  Debug.Print oHttp.responseText

来自网页的响应位于 XMLHTTP 对象的 .responseText 属性中。你如何处理这个超出了我的范围。我知道一位 Access 新闻组专家发布了有关使用 Access Web 服务的教程,但我找不到它。本文可能与该问题有关:

http://support.microsoft.com /kb/285329/en-us

This is an incomplete answer, but it should get you started (I've not worked with XML data as return).

This code has the basics:

  Dim oHttp As Object

  Set oHttp = CreateObject("Microsoft.XMLHTTP")
  oHttp.Open "GET", "https://isbndb.com/api/books.xml?access_key=YourKey&results=texts&index1=isbn&value1=YourISBN", False
  oHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
  oHttp.Send vbNullString
  Debug.Print oHttp.responseText

The response from the web page is in the .responseText property of the XMLHTTP object. How you process that is beyond me. I know that one of the Access newsgroup gurus has published a tutorial on consuming web services from Access, but I can't locate it. This article might have something to do with the issue:

http://support.microsoft.com/kb/285329/en-us

难忘№最初的完美 2024-09-01 12:00:16

您可以使用美国国会图书馆的 MARC21 XML。

我做了和你一样的事情,建立了一个数据库来容纳我的图书馆。扫描 ISBN 会从此 URL 收集数据
http://z3950.loc。 gov:7090/voyager?version=1.1&operation=searchRetrieve&query=YOUR_ISBN&maximumRecords=1

然后,响应数据将填写包含所有数据的表单。您不需要帐户,只需要该 URL。

响应采用 XML 形式(如前所述),您可以使用任何您想要的语言从那里进行解析(我的选择恰好是 PHP)。

You can use the MARC21 XML from the Library of Congress.

I did the same thing as you, building a database to house my library. Scanning in the ISBN collects the data from this URL
http://z3950.loc.gov:7090/voyager?version=1.1&operation=searchRetrieve&query=YOUR_ISBN&maximumRecords=1

The response data then fills in a form with all the data. You don't need an account, just that URL.

The response comes in XML (as mentioned), and you can parse from there using whatever language you want (my choice happens to be PHP).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文