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 BookSearchAPI。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、Amazonの製品カテゴリに対応しているようです。多分あなたはそこにもっと多くの情報を見つけるでしょう。

于 2011-02-05T13:21:36.187 に答える
0

Amazon APIをいじってみると、必要な種類の情報が提供されていないようです。

彼らはドキュメントでそのタイプのカテゴリについて言及しておらず、APIが送信するものをシリアル化した場合、フィクションまたはノンフィクションのカテゴリについての言及は1つもありません。

これを使用して、APIが送信するすべてのものを含む素敵なXML文字列を印刷できます(読みやすいようにファイルに転送することをお勧めします)。

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 に答える