goodreads api的python包装器

Goodreads的Python项目详细描述


Build StatusCoverage StatusDocumentation StatusDownloadsLatest VersionSupported Python versionsLicense

http://s.gr-assets.com/assets/icons/goodreads_icon_50x50-823139ec9dc84278d3863007486ae0ac.png

这个包为Goodreads API提供了一个python接口。使用它,你可以做很多 Goodreads允许对他们自己的数据做的任何事情。

依赖关系

此软件包取决于以下软件包:

  • xmltodict
  • 请求
  • 劳思

可以使用pip安装它们。

sudo pip install -r requirements.txt

如果您想对此包作出贡献,您将需要nose 包装也一样。

安装

要安装,请从顶级包运行以下命令 目录

sudo python setup.py install

开始

第一件事是向goodreads请求一个api密钥 here。一旦你拥有了它,你就可以 创建一个客户端实例来查询goodreads。

fromgoodreadsimportclientgc=client.GoodreadsClient(<api_key>,<api_secret>)

要访问某些方法,您需要OAuth 为了授权。

gc.authenticate(<access_token>,<access_token_secret>)

注意access_tokenaccess_token_secret是不同的 来自开发人员密钥和机密。对于开发步骤,您可以致电 同一个函数没有参数来获得授权。它会打开的 指向goodreads页以获得oauth权限的url。为了你的 应用程序,您可以将用户指向特定的url,询问他/她 授权应用并保存返回的access_tokenaccess_token_secret在数据库中。

示例

这个包为大多数goodreads api方法提供了一个python接口。 这里有几个例子演示如何访问goodreads上的数据。

书籍

让我们访问添加到goodreads的第一本书!这是一本有身份证的书 一。

book=gc.book(1)

一旦拥有了该书的GoodreadsBook实例,就可以 访问查询图书的数据。

>>>book.titleu'Harry Potter and the Half-Blood Prince (Harry Potter, #6)'>>>authors=book.authors>>>authors[0].nameu'J.K. Rowling'>>>book.average_ratingu'4.49'

作者

你也可以得到关于作者的信息。

>>>author=gc.author(2617)>>>author.nameu'Jonathan Safran Foer'>>>author.works_countu'13'>>>author.books[ExtremelyLoudandIncrediblyClose,EverythingIsIlluminated,EatingAnimals,TreeofCodes,EverythingisIlluminated&ExtremelyLoudandIncrediblyClose,Theunabridgedpocketbookoflightning,TheFutureDictionaryofAmerica,AConvergenceofBirds:OriginalFictionandPoetryInspiredbyJosephCornell,NewAmericanHaggadah,TheSixthBorough]

用户

用户数据可以通过用户id或用户名检索。

>>>user=gc.user(1)>>>user.nameu'Otis Chandler'>>>user.user_nameu'otis'>>>user.small_image_urlu'http://d.gr-assets.com/users/1189644957p2/1.jpg'

让我们找一个小组来讨论python并获得更多关于它的信息。

>>>g=gc.find_groups("Python")>>>g=groups[0]>>>g['title']u'The Computer Scientists'>>>group=gc.group(g['id'])>>>group.descriptionu'Only for Committed Self Learners and Computer Scientists Who are Starving forInformation,andWanttoAdvancetheirSkillsThrough:Reading,PracticingandDiscussionComputerScienceandProgrammingBooks.'

事件

goodreads api还允许列出一个区域中发生的事件。

>>>events=gc.list_events(21229)>>>event=events[0]>>>event.titleu'Books and Cocktails'>>>event.addressu'120 N. Front St.'>>>event.cityu'Wrightsville'

文档

阅读有关此软件包的详细信息 here

贡献

如果发现此包不支持的api方法,请感觉 免费创建github问题。另外,欢迎您提交 请求错误修复或附加功能的请求。

许可证

MIT License

确认

感谢Paul Shannon为 在pypi提供“goodreads”包。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java传递实现接口的内部类   java为什么managedbean方法在post请求中的过滤器调用之前调用   java Android应用程序在Android M,O上崩溃,登录A/libc时出错:tid 17938中的致命信号11(SIGSEGV),代码2,故障地址0x343a2944   java JPA存储库。findByAll()返回null,但数据库中存在所有内容   用于发送电子邮件的java Ant脚本   Java小程序HTML页面发生了奇怪的事情   在Postman的请求正文中传递多个JSON数据,并使用Jersy(JXRS)进入Java Rest API   无法强制转换java DAO类   10分钟后重新连接java   正则表达式如何在java中选择字符串直到某个字符   java我的输出有一些问题   Objective中的java时间段   java如何在新屏幕上基于按钮单击在webview中打开url   java哪个selenium版本与Firefox ESR 45.2.0兼容   java无法使用Apache Camel 3.1.0将XML转换为JSON