2011-02-05 55 views
2

爲了我個人的目的,我有大約300名作者(全名)的各種書籍。我想把這個列表分成「小說作者」和「非小說作者」。如果一個作者寫兩個,那麼大多數人都會得票。將書籍作者分類爲小說與非小說

我看着亞馬遜產品搜索API:我可以按作者(in Python)搜索,但沒有辦法找到的書類(小說VS休息):

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

我有哪些選擇?我更喜歡在Python中這樣做。

+1

您可以在Google上搜索「作者姓名小說」和「作者姓名非小說作品」? – btilly 2011-02-05 05:26:08

+0

@btilly - 有趣的是,「理查德道金斯小說」比「理查德道金斯非小說類」返回*更多結果。 – 2011-02-05 17:16:26

+0

所以按照你的標準,他應該被歸類爲小說寫作。我不同意這個結論;根據你的評論來判斷,你也不會。所以你需要調整你的標準。 – 2011-02-05 18:09:56

回答

4

那麼,你可以嘗試另一種服務 - 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> 

當然,此協議爲您提供了一些開銷信息,與這本書(就像谷歌圖書等可見或不可見)

2

您是否看過BrowseNodes?對我來說(誰以前沒有使用這個API)似乎BrowseNodes對應於亞馬遜的產品類別。也許你會在那裏找到更多信息。

0

在花費了一些時間與亞馬遜API搞砸之後,看起來他們沒有提供您想要的信息。

他們沒有在他們的文檔中提到這種類型的類別,並且如果您將api發送給您的東西序列化,那麼就不會提及小說或非小說類的東西。

你可以使用它打印出一個很好的XML字符串(你可能想把它指向一個文件以方便閱讀)和api發送的所有東西。

from lxml import etree 

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

print etree.tostring(node, pretty_print=True)