Created
September 14, 2017 12:25
-
-
Save hughdbrown/ee5c41538fd0ec660e02003da5fd43a0 to your computer and use it in GitHub Desktop.
Use aim endpoint
This file contains hidden or 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 python3 | |
import logging | |
import requests | |
SIGNIN_URL = "http://10.0.0.2/sign-in" | |
AIM_URL = "https://10.0.0.2/aim" | |
PID = "59ba0a1a100d2b744e4303e7" | |
FORMAT = '%(asctime)-15s %(message)s' | |
logging.basicConfig(format=FORMAT, level=logging.INFO) | |
LOGGER = logging.getLogger(__name__) | |
def get_cookie(auth_dict): | |
return { | |
'dr_lang_code': 'en', | |
'session': 'eyJfcGVybWFuZW50Ijp0cnVlLCJzZXNzaW9uX2lkIjoiMjQ0ZGRlMTUtNGNhOS00ZTM1LTgxMjQtNWY1YWQ2MWM3YjI1IiwidXNlciI6Imh1Z2guYnJvd25AZGF0YXJvYm90LmNvbSJ9', | |
} | |
LOGGER.info("auth_dict = {0}".format(auth_dict)) | |
with requests.Session() as session: | |
res = session.post(SIGNIN_URL, data=auth_dict) | |
LOGGER.info("res = {0}".format(res)) | |
assert res.status_code == 200, res.content | |
cookie = res.cookies['session'] | |
LOGGER.info("cookie = {0}".format(cookie)) | |
return cookie | |
def run_time_series( cookie): | |
payload = { | |
"use_time_series": True, | |
"pid": PID, | |
"target": "y", | |
} | |
r = requests.post(AIM_URL, data=payload, cookies=cookie) | |
LOGGER.info(r) | |
def main(): | |
# credentials on vagrant server | |
auth_dict = { | |
'signInInputUsername': '[email protected]', | |
'signInInputPassword': 'testing123', | |
} | |
auth_dict = { | |
'username': '[email protected]', | |
'password': 'testing123', | |
} | |
cookie = get_cookie(auth_dict) | |
run_time_series(cookie) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment