petfinder api的包装器

petp的Python项目详细描述


Petpy-Petfinder API的Python包装器

Documentation StatusBuild StatusCoverage StatuscodecovCodacy Badgehttps://pypi.org/project/petpy/https://pypi.org/project/petpy/

:cat2::dog2::公鸡::兔子2::赛马:

petpy是用于Petfinder API的易于使用和方便的python包装器。

安装

petpy很容易通过pip安装。

pipinstallpetpy

库也可以克隆或下载到您选择的位置,然后使用setup.py安装 按以下方式归档:

gitclonegit@github.com:aschleg/petpy.gitcdpetpypythonsetup.pyinstall

示例和用法

必须首先使用Petfinder创建帐户才能接收API和secret 钥匙API和密钥将用于授予对Petfinder API的访问权限,该权限将持续3600秒,或者 小时身份验证期结束后,必须使用petfinder api重新进行身份验证。以下是一些 使用petpy开始的快速示例。关于petpy的更深入的教程以及 可以使用库完成,请参阅下面的更多示例和教程部分。

使用petfinder api进行身份验证

在初始化Petfinder类的同时,验证与petfinder api的连接。

pf=Petfinder(key=key,secret=secret)

寻找动物类型

# All animal types and their relevant data.all_types=pf.animal_types()# Returning data for a single animal typedogs=pf.animal_types('dog')# Getting multiple animal types at oncecat_dog_rabbit_types=pf.animal_types(['cat','dog','rabbit'])

获取可用动物类型的动物品种

cat_breeds=pf.breeds('cat')dog_breeds=pf.breeds('dog')# All available breeds or multiple breeds can also be returned.all_breeds=pf.breeds()cat_dog_rabbit=pf.breeds(types=['cat','dog','rabbit'])

也可以设置breeds方法,通过设置 参数return_df = True

cat_breeds_df=pf.breeds('cat',return_df=True)all_breeds_df=pf.breeds(return_df=True)

在petfinder上查找可用的动物

animals()方法根据petfinder数据库中列出的指定条件返回动物。特定的 可以使用animal_id参数搜索动物,也可以通过输入 所需的搜索条件

# Getting first 20 results without any search criteriaanimals=pf.animals()# Extracting data on specific animals with animal_idsanimal_ids=[]foriinanimals['animals'][0:3]:animal_ids.append(i['id'])animal_data=pf.animals(animal_id=animal_ids)# Returning a pandas DataFrame of the first 150 animal resultsanimals=pf.animals(results_per_page=50,pages=3,return_df=True)

在petfinder数据库中获取动物福利组织

与上面描述的animals()方法类似,organizations()方法返回关于动物福利的数据 petfinder数据库中列出的基于特定条件的组织(如果有)。除了一般的搜索 在动物福利组织中,可以通过提供organizations()来提取特定的组织数据。 具有组织ID的方法。

# Return the first 1,000 animal welfare organizations as a pandas DataFrameorganizations=pf.organizations(results_per_page=100,pages=10,return_df=True)# Get organizations in the state of Washingtonwa_organizations=pf.organizations(state='WA')

更多示例和教程

Binder

一系列ipython笔记本,介绍和探讨 petpy库。通过单击 “启动活页夹”徽章

请注意以下笔记本仍然基于旧版本的petfinder,因此不完全 最新版本petpy和Petfinder API的功能和方法的代表这些 目前正在更新以反映petpy的新版本。

文件

要求

  • Python=3.4
  • requests>;=2.18.4
  • 尽管使用petpy并不严格要求,但是需要pandas库 以数据帧的形式返回结果

关于Petfinder.com

Petfinder.com是最大的在线可搜索数据库之一,用于在线寻找新宠物数据库包含 北美超过14000个动物收容所和收养组织的信息,将近300000只动物 可供领养。这不仅使它成为一个伟大的资源,为那些希望收养他们的新的最好的朋友, 但petfinder数据库中提供的数据和信息使其成为理想的分析工具。

许可证

麻省理工学院

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

推荐PyPI第三方库


热门话题
java的目标是从我的项目中删除不起作用的文件   java对for循环的理解   java我完成了在作业要求的位置查找字符的部分,但是如何从我找到的字符串中删除字符呢?   基于帧时的java动画   java请求无效。缺少XGoogUploadCommand标头   java如何在viewsource模式下使用openStream?   grpc grpc_ARG_KEEPALIVE_PERMIT_而不调用java服务器?   java如何通过Junit测试Web服务调用   如何在java中获取鼠标中键?   使用junit在spring测试中加载属性文件   Java中用于类的类修饰符   java多色文本图像   sql无法调试Java中的“连接到数据库失败”异常   java如何指定hibernate连接映射?   java Android工具栏不显示   java仿射转换不同的图形对象   使用终端的java问题   Java在tomcat上查找127.0.0.1失败