<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Table of Contents
<p><div class="lev1 toc-item"><a href="#Summary" data-toc-modified-id="Summary-1"><span class="toc-item-num">1&nbsp;&nbsp;</span>Summary</a></div><div class="lev1 toc-item"><a href="#Version-Control" data-toc-modified-id="Version-Control-2"><span class="toc-item-num">2&nbsp;&nbsp;</span>Version Control</a></div><div class="lev1 toc-item"><a href="#Change-Log" data-toc-modified-id="Change-Log-3"><span class="toc-item-num">3&nbsp;&nbsp;</span>Change Log</a></div><div class="lev1 toc-item"><a href="#Setup" data-toc-modified-id="Setup-4"><span class="toc-item-num">4&nbsp;&nbsp;</span>Setup</a></div><div class="lev1 toc-item"><a href="#Login()" data-toc-modified-id="Login()-5"><span class="toc-item-num">5&nbsp;&nbsp;</span>Login()</a></div><div class="lev2 toc-item"><a href="#Web-service-call" data-toc-modified-id="Web-service-call-51"><span class="toc-item-num">5.1&nbsp;&nbsp;</span>Web service call</a></div><div class="lev3 toc-item"><a href="#Get-data" data-toc-modified-id="Get-data-511"><span class="toc-item-num">5.1.1&nbsp;&nbsp;</span>Get data</a></div><div class="lev3 toc-item"><a href="#Data-inspection-(Login)" data-toc-modified-id="Data-inspection-(Login)-512"><span class="toc-item-num">5.1.2&nbsp;&nbsp;</span>Data inspection (Login)</a></div><div class="lev2 toc-item"><a href="#Helper-function" data-toc-modified-id="Helper-function-52"><span class="toc-item-num">5.2&nbsp;&nbsp;</span>Helper function</a></div><div class="lev3 toc-item"><a href="#Usage" data-toc-modified-id="Usage-521"><span class="toc-item-num">5.2.1&nbsp;&nbsp;</span>Usage</a></div><div class="lev2 toc-item"><a href="#Client-function" data-toc-modified-id="Client-function-53"><span class="toc-item-num">5.3&nbsp;&nbsp;</span>Client function</a></div>
# Summary
Part of the blog series related to making web service calls to Eoddata.com. Overview of the web service can be found [here](http
Step1:  Change Log
Date Created
Step2:  Login()
Web service call
Step3:  Get data
Step4:  Data inspection (Login)
Step5:  Helper function
Step6:  Usage
Step7:  Client function
<ASSISTANT_TASK:>
Python Code:
%run ../../code/version_check.py
Explanation: Table of Contents
<p><div class="lev1 toc-item"><a href="#Summary" data-toc-modified-id="Summary-1"><span class="toc-item-num">1&nbsp;&nbsp;</span>Summary</a></div><div class="lev1 toc-item"><a href="#Version-Control" data-toc-modified-id="Version-Control-2"><span class="toc-item-num">2&nbsp;&nbsp;</span>Version Control</a></div><div class="lev1 toc-item"><a href="#Change-Log" data-toc-modified-id="Change-Log-3"><span class="toc-item-num">3&nbsp;&nbsp;</span>Change Log</a></div><div class="lev1 toc-item"><a href="#Setup" data-toc-modified-id="Setup-4"><span class="toc-item-num">4&nbsp;&nbsp;</span>Setup</a></div><div class="lev1 toc-item"><a href="#Login()" data-toc-modified-id="Login()-5"><span class="toc-item-num">5&nbsp;&nbsp;</span>Login()</a></div><div class="lev2 toc-item"><a href="#Web-service-call" data-toc-modified-id="Web-service-call-51"><span class="toc-item-num">5.1&nbsp;&nbsp;</span>Web service call</a></div><div class="lev3 toc-item"><a href="#Get-data" data-toc-modified-id="Get-data-511"><span class="toc-item-num">5.1.1&nbsp;&nbsp;</span>Get data</a></div><div class="lev3 toc-item"><a href="#Data-inspection-(Login)" data-toc-modified-id="Data-inspection-(Login)-512"><span class="toc-item-num">5.1.2&nbsp;&nbsp;</span>Data inspection (Login)</a></div><div class="lev2 toc-item"><a href="#Helper-function" data-toc-modified-id="Helper-function-52"><span class="toc-item-num">5.2&nbsp;&nbsp;</span>Helper function</a></div><div class="lev3 toc-item"><a href="#Usage" data-toc-modified-id="Usage-521"><span class="toc-item-num">5.2.1&nbsp;&nbsp;</span>Usage</a></div><div class="lev2 toc-item"><a href="#Client-function" data-toc-modified-id="Client-function-53"><span class="toc-item-num">5.3&nbsp;&nbsp;</span>Client function</a></div>
# Summary
Part of the blog series related to making web service calls to Eoddata.com. Overview of the web service can be found [here](http://ws.eoddata.com/data.asmx).
 * ** View the master post of this series to build a secure credentials file.** It is used in all posts related to this series.
 * Download the [class definition file](https://adriantorrie.github.io/downloads/code/eoddata.py) for an easy to use client, which is demonstrated below
 * This post covers the `Login` call: http://ws.eoddata.com/data.asmx?op=Login
# Version Control
End of explanation
%run ../../code/eoddata.py
from getpass import getpass
import requests as r
import xml.etree.cElementTree as etree
ws = 'http://ws.eoddata.com/data.asmx'
ns='http://ws.eoddata.com/Data'
session = r.Session()
username = getpass()
password = getpass()
Explanation: Change Log
Date Created: 2017-03-25
Date of Change    Change Notes
--------------    ----------------------------------------------------------------
2017-03-25        Initial draft
Setup
End of explanation
call = 'Login'
url = '/'.join((ws, call))
payload = {'Username': username, 'Password': password}
response = session.get(url, params=payload, stream=True)
if response.status_code == 200:
    root = etree.parse(response.raw).getroot()
Explanation: Login()
Web service call
End of explanation
token = root.get('Token')
token
Explanation: Get data
End of explanation
dir(root)
for item in root.items():
    print (item)
for key in root.keys():
    print (key)
print(root.get('Message'))
print(root.get('Token'))
print(root.get('DataFormat'))
print(root.get('Header'))
print(root.get('Suffix'))
Explanation: Data inspection (Login)
End of explanation
def Login(session, username, password):
    call = 'Login'
    url = '/'.join((ws, call))
    payload = {'Username': username, 'Password': password}
    response = session.get(url, params=payload, stream=True)
    if response.status_code == 200:
        root = etree.parse(response.raw).getroot()
        return root.get('Token')
Explanation: Helper function
End of explanation
token = Login(session, username, password)
token
Explanation: Usage
End of explanation
# pass in username and password
eoddata = Client(username, password)
token = eoddata.get_token()
eoddata.close_session()
print('token: {}'.format(token))
# initialise using secure credentials file
eoddata = Client()
token = eoddata.get_token()
eoddata.close_session()
print('token: {}'.format(token))
# no need to manually close the session when using a with block
with (Client()) as eoddata:
    print('token: {}'.format(eoddata.get_token()))
Explanation: Client function
End of explanation
<END_TASK>