跳转到主要内容

一个用于定期收集Uber费用的简单工具。

项目描述

https://img.shields.io/pypi/v/uberfare.svg https://img.shields.io/pypi/l/uberfare.svg https://img.shields.io/pypi/pyversions/uberfare.svg https://travis-ci.org/BurnzZ/uberfare.svg?branch=master https://codecov.io/gh/BurnzZ/uberfare/branch/master/graph/badge.svg

这是一个官方Uber Python SDK的简单包装,用于从指定的时间段内收集给定起点终点的数据。

当前实现仅处理价格估算功能,因为它不需要OAuth 2.0访问。

动机

我使用这个工具来收集数据,然后评估什么时候离开家并预订Uber工作乘车,反之亦然。

需求

  • Python 3.4+

安装

我建议通过pipenv安装。

$ pipenv install uberfare
$ # or via the usual pip
$ pip3 install uberfare

API密钥

developer.uber.com/dashboard创建应用程序以获取服务器令牌 API密钥,然后

  • 创建或选择应用程序

  • 认证页面中复制服务器令牌

在使用此包之前,将您的服务器令牌导出为:export UBER_SERVER_TOKEN=<Server Token>。但是,您可以在使用CLI时覆盖此设置(见下文)。

用法

您必须确定您的位置的(纬度,经度),因为可用的乘车类型将取决于它。

获取坐标的最佳方式是访问maps.google.com,然后在地图上点击任意一点。此时,屏幕底部中央将出现一个小框,其中包含经度和纬度。请记下起点和终点的坐标。

Google Maps Coordinates Lookup

CLI

>>> # To get the fare estimate, provide the arguments: <origin>, <destination>
>>> # (Where origin and destination are in the <LATITUDE,LONGITUDE> format)
>>> uberfare estimate 14.55,121.05 14.52,121.01

>>> # To save all the RAW data in a CSV file, you can do:
>>> uberfare estimate 14.55,121.05 14.52,121.01 --output-file output.csv
CLI demo
>>> # You can also periodically fetch the Uber fares by using the
>>> # --check-interval <time in seconds> flag (short -ci):
>>> uberfare --check-interval 120 estimate 14.55,121.05 14.52,121.01
>>> uberfare -ci 120 estimate 14.55,121.05 14.52,121.01

>>> # To safely save the data in long periods of time, do:
>>> uberfare --check-interval 120 estimate 14.55,121.05 14.52,121.01 --output-file output.csv

>>> # You can override the '$UBER_SERVER_TOKEN' env variable right in the CLI via:
>>> uberfare --server_token <SERVER API KEY> estimate 14.55,121.05 14.52,121.01
>>> uberfare -st <SERVER API KEY> estimate 14.55,121.05 14.52,121.01

注意事项

在指定很短的时间间隔来检查价格时要小心,因为你可能会被限制速率。

未来版本

  • 更好的包导入界面

  • 使用地址而不是坐标的选项(使用Google Maps Geocoding API

  • 通过启用OAUTH2支持预付费数据收集。

项目详情


下载文件

下载您平台的文件。如果您不确定选择哪一个,请了解有关安装包的更多信息。

源分布

uberfare-0.1.0.tar.gz (7.6 kB 查看哈希值)

上传时间

由以下支持