Last active
November 7, 2016 12:13
-
-
Save mhl/39299103f8d269cac4cae2993cc2c3ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# This script should print out all the Twitter username for the | |
# current representatives for a particular country's lower house | |
# (Ecuador in this example, but it's easy to change). This should | |
# work on Python 2.7 and Python 3. | |
from __future__ import print_function, unicode_literals | |
from everypolitician import EveryPolitician | |
country_name = 'Ecuador' # or try 'Canada', 'UK', etc. | |
ep = EveryPolitician() | |
lower_house = ep.country(country_name).lower_house() | |
data = lower_house.popolo() | |
latest_term = sorted( | |
(e for e in data.events if e.classification == 'legislative period'), | |
key=lambda e: e.start_date | |
)[-1] | |
for m in data.memberships: | |
if m.legislative_period_id != latest_term.id: | |
continue | |
person = m.person | |
twitter_username = person.twitter | |
print(twitter_username or '?') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
approx-dates==0.0.1 | |
everypolitician==0.0.12 | |
everypolitician-popolo==0.0.10 | |
requests==2.11.1 | |
six==1.10.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment