Skip to content

Instantly share code, notes, and snippets.

@mhl
Last active November 7, 2016 12:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhl/39299103f8d269cac4cae2993cc2c3ff to your computer and use it in GitHub Desktop.
Save mhl/39299103f8d269cac4cae2993cc2c3ff to your computer and use it in GitHub Desktop.
#!/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 '?')
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