Skip to content

Instantly share code, notes, and snippets.

Last active Aug 29, 2015
What would you like to do?
redmine から json でデータを取得

Redmine からデータを JSON で取得する。

issue_number, url, username, password は適宜

#! /usr/bin/env python
# -*- coding: utf-8 -*-
if __name__ == '__main__':
import sys
import json
import urllib2
url = ''
username = 'as-you-like'
password = 'as-you-like'
password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
password_mgr.add_password(None, url, username, password)
handler = urllib2.HTTPBasicAuthHandler(password_mgr)
opener = urllib2.build_opener(handler)
res = json.loads(urllib2.urlopen(urllib2.Request('{}issues/{}.json'.format(url, int(sys.argv[1])))).read())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment