In [15]:
import requests
from IPython.display import Image
from IPython.core.display import HTML
In [16]:
query ='organizations.name:1Malaysia Development Berhad Management AND label:Chief Executive Officer'
r = requests.get('http://api.popit.sinarproject.org/en/search/posts?q='+query)
memberships = r.json()['results'][0]['memberships']
len(memberships)
Out[16]:
We now test for who held these posts between 2009 and 2013
In [17]:
from dateutil import parser
import datetime
for member in memberships:
print member['person']['name']
In [26]:
from dateutil import parser
import datetime
for member in memberships:
start_date = parser.parse(member['start_date']).date()
if member['end_date']:
end_date = parser.parse(member['end_date']).date()
else:
end_date = datetime.date.today()
#this date is in between 2009 and 2013
test_date = parser.parse('2010-01-01').date()
if start_date <= test_date <= end_date:
print member['person']['name']
print "popit id: %s" % member['id']
print member['start_date']
mugshot = Image(url=member['person']['image'],embed=True)
In [27]:
mugshot
Out[27]:
In [20]:
def citation(popit_id,fieldname):
r = requests.get('http://api.popit.sinarproject.org/en/memberships/' +popit_id + '/citations/' + fieldname)
result = r.json()['results'][0]
return {'note':result['note'],'url':result['url']}
In [21]:
del start_date
del end_date
for member in memberships:
start_date = parser.parse(member['start_date']).date()
if not member['end_date']:
end_date = 'present'
else:
end_date = parser.parse(member['end_date']).date()
print "%s was CEO from %s to %s " % (member['person']['name'], start_date, end_date)
citations = citation(member['id'],'start_date')
print "Citation for membership start: %s, %s " % (citations['note'],citations['url'])
if member['end_date']:
citations = citation(member['id'],'end_date')
print "Citation for membership end: %s \n %s " % (citations['note'],citations['url'])
print '\n'
In [ ]: