0

my python script wont to set the name and the age on the html form which has a POST method is it possible to handle with html forms in python HTML Script:

<html>


 <form action="action.php" method="post">

  <p>Votre Nom : <input type="text" name="nom" /></p>
  <p>Votre Age : <input type="text" name="age" /></p>

  <p><input type="submit" value="OK"></p>
 </form>

</html>

PYTHON script :

import urllib.request, urllib.parse, socket
data = urllib.parse.urlencode({"nom":"joe", "age":"17"}).encode('utf-8')
req = urllib.request.Request("http://127.0.0.1/index.html", data=data)
res = urllib.request.urlopen(req).read().decode()

after runing the script in the terminal all what i get is the same html code

alan
  • 3
  • 1
  • Possible duplicate of [Submitting to a web form using python](https://stackoverflow.com/questions/17509607/submitting-to-a-web-form-using-python) – ktdrv Jul 07 '17 at 16:50
  • thks sir but i have problem with the POST method not the GET one – alan Jul 07 '17 at 16:56
  • Did you actually read the [answers to that question](https://stackoverflow.com/a/17509879/276627)? – ktdrv Jul 07 '17 at 16:59

0 Answers0