Created
December 18, 2015 13:50
-
-
Save michalskop/75956254285b709dc198 to your computer and use it in GitHub Desktop.
Get Czech MEPs from hlidame.je
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
# 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