Network Programming Python - HTTP Clients Last Updated : 25 Oct, 2020 Comments Improve Suggest changes Like Article Like Report The request from the client in HTTP protocol reaches the server and fetches some data assuming it to be a valid request. This response from the server can be analyzed by using various methods provided by the requests module. Some of the ways below provide information about the response sent from the server to the Python program running on the client-side : Getting initial Response The get() method is used to get the basic information of the resources used at the server-side. This function fetches the data from the server and returns as a response object which can be printed in a simple text format. Python3 # Import libraries import requests # Sending Request req = requests.get('https://www.geeksforgeeks.org/') # Show results print(req.text[:2000]) Output: Getting session-info The session() method returns the session object which provides certain parameters to manipulate the requests. It can also manipulate cookies for all the requests initiated from the session object. If a large amount of requests are made to a single host then, the associated TCP connection is recalled. Python3 # Import Libraries import requests # Creating Session s = requests.Session() s.get('http://httpbin.org/cookies/set/sessioncookie/419735271') # Getting Response r = s.get('http://httpbin.org/cookies') # Show Response print(r.text) Output: { "cookies": { "sessioncookie": "419735271" } } Error Handling If some error is raised in processing the request to the server, the exception is raised by the program which can be handled using the timeout attribute, which defines the time value until the program waits and after that, it raises the timeout error. Python3 # Import Libraries import requests # Error Handling try: # Creating Request req = requests.get('https://www.geeksforgeeks.org/', timeout=0.000001) except requests.exceptions.RequestException as e: # Raising Error raise SystemExit(e) Output: HTTPSConnectionPool(host='www.geeksforgeeks.org', port=443): Max retries exceeded with url: / (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x0000018CFDAD83C8>, 'Connection to www.geeksforgeeks.org timed out. (connect timeout=1e-06)')) Comment More infoAdvertise with us Next Article Network Programming Python - HTTP Clients J jeeteshgavande30 Follow Improve Article Tags : Technical Scripter Python Programming Language Python-Networking Practice Tags : python Similar Reads Network Programming Python - HTTP Server HTTP Web Server is simply a process which runs on a machine and listens for incoming HTTP Requests by a specific IP and Port number, and then sends back a response for the request. Python has a built-in webserver provided by its standard library, can be called for simple client-server communication. 3 min read Network Programming Python - HTTP Requests HTTP stands for HyperText Transfer Protocol, which works on the client-server machine. In most cases, the web browser acts as the client, and the computer which hosts the website acts as a server. Python provides the requests module to play with HTTP requests. The requests module plays a major role 2 min read CGI Programming in Python What is CGI? Common Gateway Interface (also known as CGI) is not a kind of language but just a specification(set of rules) that helps to establish a dynamic interaction between a web application and the browser (or the client application). The CGI programs make possible communication between client 5 min read Socket Programming in Python Socket programming is a way of connecting two nodes on a network to communicate with each other. One socket(node) listens on a particular port at an IP, while the other socket reaches out to the other to form a connection. The server forms the listener socket while the client reaches out to the serv 6 min read Tornado- HTTP servers and clients Tornado is a Python web framework and a library for async networks. It is meant for non-blocking, highly effective apps. Tornado has become popular because it can handle large numbers of simultaneous connections easily. In this article, we will explain Tornado HTTP servers and clients. What are HTTP 4 min read Simple Calculator in Python Socket Programming In this article, we are going to know how to make a simple calculator in Python socket programming. Prerequisite: Socket Programming in Python. First, we will understand the basics of Python socket programming. Socket programming is used to set up a communication channel between two nodes on a netwo 4 min read Python Tornado - Asynchronous Networking Traditional synchronous networking models often struggle to keep pace with the demands of modern applications. Enter Tornado-Asynchronous networking, a paradigm-shifting approach that leverages non-blocking I/O to create lightning-fast, highly scalable network applications. In this article, we will 4 min read Install Aiohttp In Python Aiohttp library in Python is an asynchronous HTTP client and server framework that is built on top of the asynchronous I/O library asyncio in Python. Using this library, we can build web applications and RESTful APIs, and also we can handle synchronous HTTP requests in the application. This library 2 min read Socket Programming with Multi-threading in Python Prerequisite : Socket Programming in Python, Multi-threading in PythonSocket Programming-> It helps us to connect a client to a server. Client is message sender and receiver and server is just a listener that works on data sent by client.What is a Thread? A thread is a light-weight process that d 3 min read Network Scanning using scapy module - Python Scapy is a library supported by both Python2 and Python3. It is used for interacting with the packets on the network. It has several functionalities through which we can easily forge and manipulate the packet. Through scapy module we can create different network tools like ARP Spoofer, Network Scann 3 min read Like