Import error: Search images with DuckDuckGo ('search_images_ddg)

Hi,
When trying to import the ‘search_images_ddg’ function to download images from DuckDuckGo i get an import error:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
in
----> 1 from fastbook import search_images_ddg

ImportError: cannot import name 'search_images_ddg' from 'fastbook' (/opt/conda/envs/fastai/lib/python3.8/site-packages/fastbook/__init__.py)

When i simply copy paste the ‘search_images_ddg’ from the fastbook module and try to run it in the notebook I get an assertion error:


AssertionError                            Traceback (most recent call last)
<ipython-input-27-fe39ec9b75f1> in <module>
----> 1 urls = search_images_ddg('grizzly bear', max_images=100)
      2 len(urls),urls[0]

<ipython-input-22-dd378a2d68ad> in search_images_ddg(term, max_images)
      5     res = urlread(url,data={'q':term}).decode()
      6     searchObj = re.search(r'vqd=([\d-]+)\&', res)
----> 7     assert searchObj
      8     requestUrl = url + 'i.js'
      9     params = dict(l='us-en', o='json', q=term, vqd=searchObj.group(1), f=',,,', p='1', v7exp='a')

AssertionError: 

Would much appreciate anyones help on this one.

Thank you

Jakub


This thread might be helpful for you.

change max_images to max_n