Python – Internet Protocol
”;
The Internet Protocol is designed to implement a uniform system of addresses on all of the Internet-connected computers everywhere and to make it possible for packets to travel from one end of the Internet to the other.
A program like the web browser should be able to connect to a host anywhere without ever knowing which maze of network devices each packet is traversing on its journey. There are various categories of
internet protocols. Thes protocols are created to serve the needs of different types of data communication between different computers in the internet.
Python has several modules to handle each of these communication scenarios. The methods and functions in these modules can do the simplest job of just validating a URL or also the complex job of handling the cookies and sessions. In this chapter we will look at the most prominent python modules used for internet protocols.
Protocol | Python Module Name | Description |
---|---|---|
HTTP | urllib.request | Opening the HTTP URL |
HTTP | urllib.response | Create a reponse object for a url request |
HTTP | urllib.parse | To break Uniform Resource Locator (URL) strings up in components like (addressing scheme, network location, path etc.), |
HTTP | urllib.robotparser | It finds out whether or not a particular user agent can fetch a URL on the Web site that published the robots.txt file. |
FTP | ftplib | implements the client side of the FTP protocol. You can use this to write Python programs that perform a variety of automated FTP jobs, such as mirroring other FTP servers. |
POP | poplib | This module defines a class, POP3, which encapsulates a connection to a POP3 server to read messages from a email server |
IMAP | imaplib | This module defines three classes, IMAP4, IMAP4_SSL and IMAP4_stream, which encapsulate a connection to an IMAP4 server to read emails. |
SMTP | smtplib | The smtplib module defines an SMTP client session object that can be used to send mail to any Internet machine with an SMTP listner deamon. |
Telnet | telnet | This module provides a Telnet class that implements the Telnet protocol to access a server thorugh teleent. |
Each of them is discussed in detail in the subsequent chapters.
”;