一个用于定期收集Uber费用的简单工具。
项目描述
这是一个官方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,然后在地图上点击任意一点。此时,屏幕底部中央将出现一个小框,其中包含经度和纬度。请记下起点和终点的坐标。
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
>>> # 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的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | a4b39b6daa3585a349ea0db76d1cec4f05eeff16734fecae63dc6b88a5fc04cd |
|
MD5 | e062938343632d79576c5145d508b10c |
|
BLAKE2b-256 | 5f8692fa26a256ec1d02bba7e3418344a93d343f77458f315a18395c7dd09498 |