0

For a long time I love programming things that collects data for me. In Python I can make a GET request to a website and return the HTML of the website I would like to receive.

But in alot of websites you can POST something to the server and PHP would then respond/react on that sended data. How do I do this in Python?

For example, in the website at the bottom of this post I can insert my name and press the submit button to send the data to the PHP script. How do i do this in a socket with Python?

Also I really want to make it work without any libraries because ill be implementing it to other programs in other programming languages.

<html>
  <body>
    <form action="website.php" method="post">
  <fieldset>
   <br>
   Enter your name: 
   <input type="text" name="un"> 
   <center>
    <input type=submit value=submit>
   </center>
  </fieldset>
 </form>
  </body>
</html>
Niels
  • 13
  • 7
  • 2
    Possible duplicate of [Python: How to send POST request?](http://stackoverflow.com/questions/11322430/python-how-to-send-post-request) – roberto06 Jan 19 '17 at 10:31
  • 1
    Possible duplicate of [How to make a Python HTTP Request with POST data and Cookie?](http://stackoverflow.com/questions/9445491/how-to-make-a-python-http-request-with-post-data-and-cookie) – Torxed Jan 19 '17 at 10:31
  • 1
    Any other options would include the need for manually creating a socket, which is also pretty trivial and covered in many guides - followed by understanding the HTTP protocol which has been around for so many decades that there's literally a squillion examples of how it looks and how you can use it :) – Torxed Jan 19 '17 at 10:34
  • i found alot of tutorials and examples online, but they all use libraries :/ – Niels Jan 19 '17 at 10:36
  • @Niels, I would assume that you either look how it is done with those libraries, how they work and then try to implement it yourself, or use said libraries, as they exist for a reason in nearly every language. There are many reasons for libraries. Do not reinvent the Wheel and such... as Torxed already said, in python you do HTTP like everywhere else. Not using any libraries would mean, to reimplement all the little stuff from the ground up to HTTP itself. – krysopath Jan 19 '17 at 10:39
  • Thanks everyone for the responses, I appriciate it! i've got it working now. – Niels Feb 22 '17 at 14:04

0 Answers0