Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/353.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 将书籍作者分为小说类和非小说类_Python_Api_Amazon_Categorization - Fatal编程技术网

Python 将书籍作者分为小说类和非小说类

Python 将书籍作者分为小说类和非小说类,python,api,amazon,categorization,Python,Api,Amazon,Categorization,就我个人而言,我有大约300位不同书籍的作者(全名)。我想把这个列表分为“小说作者”和“非小说作者”。如果一位作者同时写了这两篇文章,那么大多数人都有投票权 我查看了Amazon产品搜索API:我可以按作者()进行搜索,但无法找到图书类别(小说vs rest): 我有什么选择?我更喜欢用Python来实现这一点。好吧,您可以尝试其他服务-。要使用Python,您可以看看。在其协议中,结果提要中有一个节点-可能是您需要的: <?xml version="1.0" encoding="UTF-

就我个人而言,我有大约300位不同书籍的作者(全名)。我想把这个列表分为“小说作者”和“非小说作者”。如果一位作者同时写了这两篇文章,那么大多数人都有投票权

我查看了Amazon产品搜索API:我可以按作者()进行搜索,但无法找到图书类别(小说vs rest):


我有什么选择?我更喜欢用Python来实现这一点。

好吧,您可以尝试其他服务-。要使用Python,您可以看看。在其协议中,结果提要中有一个节点
-可能是您需要的:

<?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>

http://www.google.com/books/feeds/volumes
2008-08-12T23:25:35.000
简·奥斯汀
詹姆斯·金斯利
菲奥娜斯塔福德
2004
如果一个举世公认的真理能如此迅速地缩小到
一个有点痴迷的喜剧角色的观点,读者可能会合理地感觉到。。。
382
8cp-Z_G42g4C
ISBN:0192802380
牛津大学出版社,美国
小说
傲慢与偏见
小说

当然,这个协议会给你一些与这本书相关的开销信息(比如在谷歌图书上是否可见等等)

你看过吗?对于我(以前从未使用过此API)来说,
BrowseNodes
似乎与亚马逊的产品类别相对应。也许你会在那里找到更多的信息。

在花了一些时间弄乱了Amazon API之后,他们似乎没有提供你想要的信息

他们在文档中没有提到这种类型的类别,如果你序列化api发送给你的内容,就没有提到虚构或非虚构的类别

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

from lxml import etree

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

print etree.tostring(node, pretty_print=True)

你可以在谷歌上搜索“作者姓名小说”和“作者姓名非小说”?@b很有趣,但“理查德·道金斯小说”比“理查德·道金斯非小说”返回的结果更多。因此,根据你的标准,他应该被归类为小说作家。我不同意这个结论;从你的评论来看,你也没有。因此,您需要调整您的标准。我查看了
BrowseNodes
。它列出了一些类别,但我没有看到“非小说类”类别(在amazon.com中可以看到该类别)。我现在要看Google Books API…虽然基于API的搜索不如基于web的搜索可靠(“标题:…和作者:…”API查询不会返回任何内容,但在web上会返回任何内容),而且许多书籍都没有指定主题,但此解决方案足以满足我的需要,因为它将大多数ficiton书籍归类为“虚构”主题。
from lxml import etree

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

print etree.tostring(node, pretty_print=True)