Skip to content

Instantly share code, notes, and snippets.

@ApplyHiTech
Last active November 9, 2015 18:24
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 ApplyHiTech/4307fab2ff3308bad56c to your computer and use it in GitHub Desktop.
Save ApplyHiTech/4307fab2ff3308bad56c to your computer and use it in GitHub Desktop.

Created by Jai-Chaudhary Nov 2015

Download Session IDs by Opening Chrome, Logging into Empatica, Clicking All Sessions. Then, click (F12), console tab and enter following commands

var sessionIDs = []
$(".sessionID").each(function() {
    sessionIDs.push($(this).text());    
});
JSON.stringify(sessionIDs)

the output will be an array of session IDs you can copy paste below

sessionIDs = ["95020",...,"85874"]
len(sessionIDs)

The following block downloads the zipfile from empathica. All you may need to change is the cookie. It created a data/<sessionID> directory and adds csv files to it

import requests, zipfile, StringIO

cookie = {'connect': 'example1234', 'session_id': 'example12345'}

url = "https://www.empatica.com/connect/download.php"

headers = {
    'cache-control': "no-cache",
    'postman-token': "example1234"
    }

for sessionID in sessionIDs:
    querystring = {"id":sessionID}
    print querystring
    response = requests.request("GET", url, headers=headers, params=querystring, cookies= cookie)

    fileInstance = zipfile.ZipFile(StringIO.StringIO(response.content))
    fileInstance.extractall('./data/' + querystring["id"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment