#
# Get Authentication Ticket
#
import httplib, urllib
params = urllib.urlencode({'username': 'xxx', 'password': 'yyy'})
headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
conn = httplib.HTTPSConnection("technet.rapaport.com")
conn.request("POST", "/HTTP/Authenticate.aspx", params, headers)
response = conn.getresponse()
auth_ticket = response.read()
conn.close()
#
# Get the download
#
import httplib, urllib
try:
output_file = open('download.csv', 'w')
params = urllib.urlencode({ 'ticket': auth_ticket })
headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
conn = httplib.HTTPConnection("technet.rapaport.com")
url = "/HTTP/DLS/GetFile.aspx"
conn.request("POST", url, params, headers)
response = conn.getresponse()
data = response.read()
output_file.write( data )
conn.close()
output_file.close()
except IOError:
output_file = open('download.csv', 'w')
output_file.close()
|