So, in the earlier recipe, we saw how to make HTTP requests, and you also learnt how to parse a web response. It's time to move ahead and download content from the Web. You know that the WWW is not just about HTML pages. It contains other resources, such as text files, documents, and images, among many other formats. Here, in this recipe, you'll learn ways to download images in Python with an example.
To download images, we will need two Python modules, namely
urllib2. We could use the
requests module instead of
urrlib2, but this will help you learn about
urllib2 as an alternative that can be used for HTTP requests, so you can boast about it.