Skip to content

Instantly share code, notes, and snippets.

@michalskop
Created December 18, 2015 13:50
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 michalskop/75956254285b709dc198 to your computer and use it in GitHub Desktop.
Save michalskop/75956254285b709dc198 to your computer and use it in GitHub Desktop.
Get Czech MEPs from hlidame.je
# get all Czech MEPs
# importing necessary packages
import requests
import json
import csv
# get the data
url = "http://api.hlidame.je/rest/hlidame/people?app_name=hlidame"
r = requests.get(url)
data = r.json()
with open("data.csv","w") as fout: # saving into this file ("w" = open for writing)
csvw = csv.writer(fout) # set writer
for mep in data['record']: # go through every record
if mep['country_code'] == 'cz': # if Czech
csvw.writerow([mep['name'], mep['party_code']]) #write
#
# SMS when done:
from twilio.rest import TwilioRestClient #import Twilio
import sms_authentication
#ACCOUNT_SID = "AC4xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
#AUTH_TOKEN = "aexxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
client = TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN)
client.messages.create(
to="+420775187021",
from_="+420736350993",
body="Go go Kacenky go!"
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment