2

出于我个人的目的,我有大约 300 位不同书籍的作者(全名)。我想将此列表划分为“小说作者”和“非小说作者”。如果一个作者都写了这两个,那么大多数人都会获得投票。

我查看了 Amazon Product Search API:我可以按作者搜索(在 Python 中),但无法找到图书类别(小说与休息):

>>> node = api.item_search('Books', Author='Richard Dawkins')
>>> for book in node.Items.Item:
...     print book.ItemAttributes.Title

我有哪些选择?我更喜欢在 Python 中执行此操作。

4

3 回答 3

4

好吧,您可以尝试另一种服务——Google Book Search API。要使用 Python,您可以查看gdata-python-api。在其协议中,结果提要中有一个节点<dc:subject>- 可能就是您所需要的:

<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"
      xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/"
      xmlns:gbs="http://schemas.google.com/books/2008" 
      xmlns:dc="http://purl.org/dc/terms"
      xmlns:gd="http://schemas.google.com/g/2005">
  <id>http://www.google.com/books/feeds/volumes</id>
  <updated>2008-08-12T23:25:35.000</updated>

<!--  a loot of information here, just removed those nodes to save space.. -->

    <dc:creator>Jane Austen</dc:creator>
    <dc:creator>James Kinsley</dc:creator>
    <dc:creator>Fiona Stafford</dc:creator>
    <dc:date>2004</dc:date>
    <dc:description>
      If a truth universally acknowledged can shrink quite so rapidly into 
      the opinion of a somewhat obsessive comic character, the reader may reasonably feel ...
    </dc:description>
    <dc:format>382</dc:format>
    <dc:identifier>8cp-Z_G42g4C</dc:identifier>
    <dc:identifier>ISBN:0192802380</dc:identifier>
    <dc:publisher>Oxford University Press, USA</dc:publisher>
    <dc:subject>Fiction</dc:subject>
    <dc:title>Pride and Prejudice</dc:title>
    <dc:title>A Novel</dc:title>
  </entry>
</feed>

当然,此协议会为您提供一些与本书相关的开销信息(例如在 Google 图书上可见或不可见等)

于 2011-02-05T13:17:15.267 回答
2

你看了BrowseNodes吗?对我(以前没有使用过这个 API)来说,它似乎BrowseNodes对应于亚马逊的产品类别。也许你会在那里找到更多信息。

于 2011-02-05T13:21:36.187 回答
0

在花了一些时间弄乱 Amazon API 之后,看起来他们没有提供您想要的信息。

他们在他们的文档中没有提到该类型的类别,如果您对 api 发送给您的内容进行序列化,则没有提及小说或非小说类别。

您可以使用它打印出一个漂亮的 XML 字符串(您可能希望将其指向一个文件以便于阅读)以及 api 发送的所有内容。

from lxml import etree

node = api.item_search('Books', Author='Richard Dawkins')

print etree.tostring(node, pretty_print=True)
于 2011-02-05T19:27:24.757 回答