1
I want to turn the form (which is working) into a URL to run in the backend
<form action="/users/login?ssrc=head&returnurl=https%3a%2f%2fpt.stackoverflow.com%2f" method="post">
<input type="text" name="email"></input>
<input type="password" name="password"></input>
<input type="submit" value="enviar"></input>
</form>
Python Curl try:
import urllib
url = '/users/login?ssrc=head&returnurl=https%3a%2f%2fpt.stackoverflow.com%2f'
values = {'email': '[email protected]', 'password' : '$teste123','submit': 'SUBMIT'}
dados = urllib.urlencode(values)
html = urllib.urlopen(url,dados).read()
print (html)
Thanks! Which of the 2 ways is better? #modo1 r = requests.post(url, data=value) print(r. text) "" #Modo2 data = urllib.parse.urlencode(value) html = urllib.request.urlopen(url, data.Encode(). read(). Decode() print (html)
– DaniloAlbergardi
@Daniloalbergardi personally prefer to use requests for knowing better and for me to be simpler. But you achieve the same with urlib, it’s a matter of taste
– Miguel
@Daniloalbergardi on your question: http://stackoverflow.com/questions/2018026/what-are-the-differences-between-the-urllib2-and-requests-module
– Miguel
OK, thank you very much!
– DaniloAlbergardi