Programming for the Web with HTTP

In the chapter, you will learn how to use Python as an HTTP client to make requests and retrieve web resources. You will be encouraged to try a series of example requests. We will compare urllib and the third-party requests library and show you the differences when working with forms and cookies. The third-party Requests package is a very popular alternative to urllib. It has an elegant interface and a powerful feature set, and it is a great tool for streamlining HTTP workflows. We also cover HTTP authentication mechanisms and how we can manage them with the Requests module.

The following topics will be covered in this chapter:

  • Understanding the urllib package to query a REST API
  • Understanding the Requests package to query a REST API
  • Handling forms with urllib and requests with Python 3.7
  • Handling cookies with urllib and requests with Python 3.7
  • Handling HTTPS and HTTP Basic Authentication with requests

The urllib package is the recommended Python standard library package for HTTP tasks. The standard library also has a low-level module called HTTP. Although this offers access to almost all aspects of the protocol, it has not been designed for everyday use. The urllib package has a simpler interface, and it deals with everything that we are going to cover in this chapter.

The third-party Requests package is a very popular alternative to urllib. It has an elegant interface and a powerful feature set, and it is a great tool for streamlining HTTP workflows.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset