The code below gives the following output:
Why is the function not fetching the URLS properly?
! [ -e /content ] && pip install -Uqq fastbook
from fastbook import *
from fastai.vision.widgets import *
results = search_images_ddg('grizzly bear')
ims = results.attrgot('contentUrl')
change your line 'ims = results.attrgot(‘contentUrl’) just to ‘ims = results’ as the search_images_ddg() method returns the urls directly.
Checkout the source code: fastbook/utils.py at master · fastai/fastbook · GitHub
You can see that it returns the urls directly, I think the api is slightly different than the bing search method that was there previously. The attrgot method from fastcore returns a new ‘L’ objects that safely defaults to None if it doesn’t grab an object if I’ve read the source correctly: fastcore - Foundation
So your results object is actually already what you’re looking for, take away the .attrgot() call and you should be good to go, hope that helps!