Страница на которую должен входить бот выглядит вот так
<html>
<body>
привет аннонимус
<form action="." method="post"> <div style='display:none'><input type='hidden' name='csrfmiddlewaretoken' value='a04b042abeaf09a195fa4ae4558a003f' /></div>
<label for="username">login:</label>
<input type="text" name="username" >
<label for="password">password:</label>
<input type="password" name='password>
<input type="submit" value="Submit">
</form>
</body>
</html>
>>> import urllib2
>>> params = urllib.urlencode({'username':'roma', 'password':'230678'})
>>> print params
username=roma&password=230678
>>> url = 'http://127.0.0.1:8000/index/'
>>> print url
http://127.0.0.1:8000/index/
>>> html = urllib2.urlopen(url, params)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/urllib2.py", line 126, in urlopen
return _opener.open(url, data, timeout)
File "/usr/lib/python2.6/urllib2.py", line 397, in open
response = meth(req, response)
File "/usr/lib/python2.6/urllib2.py", line 510, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python2.6/urllib2.py", line 435, in error
return self._call_chain(*args)
File "/usr/lib/python2.6/urllib2.py", line 369, in _call_chain
result = func(*args)
File "/usr/lib/python2.6/urllib2.py", line 518, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 403: FORBIDDEN