Downloading images - Book Chapter 2


I’m trying to download the images for the grizzly bears in Chapter 2 without success. I’m working through the book and I’m using Colab. My attempts are below.

Can anybody please provide some guidance? I don’t know which folder the images are being saved to…

Much appreciated.


!pip install -Uqq fastbook

import fastbook



from fastbook import *

from import *

key = os.environ.get(‘AZURE_SEARCH_KEY’, ‘xxx’)

results = search_images_bing(key, ‘grizzly bear’)

ims = results.attrgot(‘content_url’)


dest = ‘images/grizzly.jpg’

download_url(ims[0], dest)

im =


MissingSchema Traceback (most recent call last)
in ()
1 dest = ‘images/grizzly.jpg’
----> 2 download_url(ims[0], dest)
4 im =
5 im.to_thumb(128,128)

5 frames
/usr/local/lib/python3.6/dist-packages/requests/ in prepare_url(self, url, params)
386 error = error.format(to_native_string(url, ‘utf8’))
–> 388 raise MissingSchema(error)
390 if not host:

MissingSchema: Invalid URL ‘None’: No schema supplied. Perhaps you meant http://None?


ims = results.attrgot(‘content_url’)

ims = results.attrgot(‘contentUrl’)

The book and repo both have an error in this line:

ims = results.attrgot(‘content_url’)

If you print the results, you can see that the Bing Search API uses the variable “contentUrl” not “content_url”:

‘contentUrl’: ‘’,

So the referenced line needs to be changed to:

ims = results.attrgot(‘contentUrl’)

There is an additional certificate error bug in some environments that prevents this from running that appears to have been closed:

According to the report, it’s been resolved for Paperspace instances, but it’s still broken in Google Colab. You’ll probably need to switch to Paperspace to keep working through book.


Thanks Poodleman. Yes, I was having some teething issues with using Colab. I haven’t used Paperspace yet but will look into it if that is slicker with the FastAI API.

Much appreciated.

Hi there
I am getting this same error right now.
I tried changing the code as per the reply above, but to no avail. Please help.

Thank you so much in advance. Much appreciated.