I want use request to post the form with python and request This is form with 2 value user and pass to submit them
<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
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.