【问题标题】:Categorize book authors as fiction vs non-fiction将书籍作者分类为小说与非小说
【发布时间】:2013-05-01 05:03:06
【问题描述】:

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

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

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

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

【问题讨论】:

  • 您可以在 Google 上搜索“作者姓名小说”和“作者姓名非小说”吗?
  • @btilly - 很有趣,但“Richard Dawkins 小说”比“Richard Dawkins non-fiction”返回 更多 个结果。
  • 所以按照你的标准,他应该被归类为小说作家。我不同意这个结论;从您的评论来看,您也没有。所以你需要调整你的标准。

标签: python api amazon categorization


【解决方案1】:

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

<?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 图书上可见或不可见等)

【讨论】:

  • 虽然基于 API 的搜索不如基于 Web 的搜索可靠(“标题:.. 和作者:..”API 查询不会返回任何内容,但会在网络上返回)和许多书籍没有分配主题,这个解决方案足以满足我的需求,因为它将大多数小说书籍归类在“小说”主题下。
【解决方案2】:

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

【讨论】:

  • 我看了BrowseNodes。它列出了一些类别,但我没有看到“非小说类”类别(该类别在 amazon.com 中是可见的)。我现在要去看看 Google Books API ...
【解决方案3】:

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

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

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

from lxml import etree

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

print etree.tostring(node, pretty_print=True)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-05-30
    • 2020-09-15
    • 2020-08-26
    • 2016-07-18
    • 2021-04-30
    • 2020-06-05
    • 2013-10-19
    相关资源
    最近更新 更多