Make Your Python Socket Talk to the Internet

This post will show you how to make your Python socket talk to an application on another web server.

Once you establish a connection with your socket, you can use Python to browse web data. The most common protocol is HTTP (HyperText Transport Protocol). HTTP is a set of rules to allow browsers to retrieve web documents from servers over the internet.

python socket
Use this code to establish a socket in Python.

Examining the URL

Look at the URL in your location field or address bar of your web browser. It can be broken down into three parts.

For example, consider the URL http://dr-chuck.com/page1.htm.

  1. The first part is the “http”. This tells you what protocol is being used.
  2. The second part, “dr-chuck.com”, refers to the host you want to talk to.
  3. The last part, “page1.htm”, refers to the file you want to retrieve.

Every time you click on a link to get a new page on the internet, your browser initiates a request / response cycle to GET the new page. This, in a nutshell, is the act of surfing the web.

Web Surfing
The act of surfing…the web.

Leave a Reply

Your email address will not be published. Required fields are marked *