Question

I want use request to post the form with python and request This is form with 2 value user and pass to submit them

can you help me pls .

    <form method="post" action="/maxverif/0" name="loginf" id="connect">
    <p class="title">
    Connect
    </p>
    <div class="before">
      <div class="ques">
        <div class="name">Mail :</div>
        <div class="input"><input type="text" name="user"/></div>

      </div>
      <div class="question">
        <div class="name">Pass</div>
        <div class="input"><input type="password" name="pass"  /></div>
      </div></div>
    <div>
      <div class="button">
        <input type="submit" value="trens" id="connect" />
                  </div>

python :

import requests
 url = 'https://www.domains.com/store/verify/'


parameters2 = {'user': 'hhhhh@gmail.com',
              'pass': '123456'
               }

params = urllib.urlencode(parameters2)


req = urllib2.Request(url, params)


response = urllib2.urlopen(req)
data=response.read()
html= etree.HTML(data)
print html

And when I make Print html and i see the form is not posted . Tks

Was it helpful?

Solution

Hi i found a solution and i make this

cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
login_data = urllib.urlencode({'user': 'hhhhh@gmail.com', 'pass': '123456'})
opener.open('https://www.domains.com/store/verify/', login_data)
hh = opener.open('https://www.domains.com/store/verify/', login_data)
print hh.read()

Tks

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top