Python post to remote host
<p>Hi I want to write robot to register in toefl test , I send request to remote web site as:</p>

<pre><code>from django.http import HttpResponse

import requests

from bs4 import BeautifulSoup
from django.middleware import csrf


def index(request):
    session = requests.Session()
    page = session.get('https://toefl-registration.ets.org/TOEFLWeb/extISERLogonPrompt.do')


    if request.method == 'POST':
        url = 'https://toefl-registration.ets.org/TOEFLWeb/logon.do'
        data = {
                'password': request.POST.get('password', ''),
                'username': request.POST.get('username', ''),
                'org.apache.struts.taglib.html.TOKEN': request.POST.get('org.apache.struts.taglib.html.TOKEN', '')
               }

        page = session.post(url, data=data)


    return HttpResponse(request,page.text)
</code></pre>

<p>My post request is not same as post request made by toefl original web site and instead of login shows error as : We are sorry, our servers are currently busy. Please wait a few minutes and retry your request.</p>

<p>what is the problem? someone in other corporation did this without error</p>

<p>you should make sure that you enter cookies correctly like:</p>

<pre><code>def index(request):

response = HttpResponse()
if 'JSESSIONID' in request.COOKIES:
    print('1')
else:
    session = requests.Session()
    page = session.get('https://toefl-registration.ets.org/TOEFLWeb/extISERLogonPrompt.do')
    cookie = page.cookies
    for c in cookie:
        response.set_cookie(c.name, c.value)

iud = '1'
if request.method == 'POST':
    url = 'https://toefl-registration.ets.org/TOEFLWeb/logon.do'
    iud = '2'
    page = requests.post(url, data=data, cookies=request.COOKIES)
    cookie = page.cookies



response.write(pageReader(request, page.text, iud))
return response
</code></pre>

python django