Hi,
I'm trying to solve the first programming exercise, but I'm stuck with the authentification part of the problem : getting the program to login with HTS.
For that I followed the instructions of the httplib2's tutorial
Here is a trimmed version of my script (without the algorithmic part solving the problem)
I tried different variations without success. I would be very happy if someone tells me what I'm missing.
- Code: Select all
#!/usr/bin/python
# -*- coding: iso-8859-15 -*-
import httplib2
import urllib
import urllib2
def main():
http = httplib2.Http()
url = "http://www.hackthissite.org/user/login"
body = {'username': '*******', 'password': '*******'}
headers = {'Content-type': 'application/x-www-form-urlencoded'}
response, content = http.request(url, 'POST', headers=headers, body=urllib.urlencode(body))
headers['Cookie'] = response['set-cookie']
url = "http://www.hackthissite.org/missions/prog/1/"
response, content = http.request(url, 'GET', headers=headers)
if content.find("Login Required") > 0:
print "Login failed"
else:
print "Login succeeded"
if __name__=='__main__':
main()



