Skip to content

Instantly share code, notes, and snippets.

@TakesxiSximada
Created May 16, 2015 16:01
Show Gist options
  • Save TakesxiSximada/1d267b9a582be30e8eca to your computer and use it in GitHub Desktop.
Save TakesxiSximada/1d267b9a582be30e8eca to your computer and use it in GitHub Desktop.
大谷のデータ取得
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""大谷のデータ取得
"""
import sys
import argparse
import requests
def main(argv=sys.argv[1:]):
parser = argparse.ArgumentParser()
parser.add_argument('domain')
args = parser.parse_args(argv)
url = 'https://{}/packathon/apiv0/dp/data/master/player_master'.format(args.domain)
params = {
'count': '',
'limit': 1,
'sort': 'player_short_name,player_no',
'filter': "team.name eq '日本ハム' and player_no eq '11'",
'pretty': '',
}
res = requests.get(url, params=params)
data = res.json()
for ii, player in enumerate(data.get('results', [])):
print('- {}'.format(ii))
for key, value in sorted(player.items()):
print(' {}: {}'.format(key, value))
print(data.get('count'))
print(res.url)
print('{}: {}'.format(res.status_code, res.reason))
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment