HOWTO Fetch Internet Resources Using The urllib Package Release 3.9.5 Guido van Rossum and the Python development team June 01, 2021 Python Software Foundation Email: docs@python.org Contents 1 Introduction 2 2 Fetching URLs 2 2.1 Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2.2 Headers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 3 Handling Exceptions 4 3.1 URLError . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 3.2 HTTPError . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 3.3 Wrapping it Up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 4 info and geturl 7 5 Openers and Handlers 8 6 Basic Authentication 8 7 Proxies 9 8 Sockets and Layers 10 9 Footnotes 10 Index 11 Author Michael Foord Note: There is a French translation of an earlier revision of this HOWTO, available at urllib2 - Le Manuel manquant. 1