URL PROCESSING

The urllib module actually provides methods for downloading files, as we've already seen in Chapter 12. It also contains a number of functions for processing/converting URLs into useful formats in the same way as the Perl URI::Escape. The functions in each are summarized in Table 13.1.

Table 13.1. Converting URL to/from escaped versions
Perl URI::Escape Python urllib Description
uri_escape(string) urllib.quote (string) Escapes characters in string with URL compatible formats. Note that the Python quote() does not convert spaces to + characters by default (uri_escape() does). Use the quote_plus() function instead
uri_unescape(string) urllib.unquote (string) Converts a string that has URL escape sequences embedded into it in a normal ...

Get Perl To Python Migration now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.