Ddg_images doesnt return any results

I am currently reviewing the first part of the course because it has been a couple of weeks since I last looked at it and am stuck at searching urls with the ddg_images function.

The method used in the video course didnt work for me, so I used the method presented in the according kaggle notebook. The last time I used it it worked, this time it didnt and I dont know why.

from duckduckgo_search import ddg_images
from fastcore.all import *

def search_images(term, max_images=30):
    print(f"Searching for '{term}'")
    return L(ddg_images(term, max_results=max_images)).itemgot('image')

This function will return a empty list no matter the input term, but it wont throw any exceptions.

Does anybody know what the problem could be?

if you want the function on the video to work import this first

import fastbook
from fastbook import *

and then search_images_ddg will work :slight_smile:


Yes it worked, dont know how that slipped past me when I tried it :sweat_smile:
Thank you!

1 Like

I’m having the same problem, did the recommended fix and still am not getting any results. Using Python3.9 on Mac Intel

Guys, I think its not an issue with any import or library. It seems like ddg is blocking the ip address. So when you restart the router/ change public ip address it will work for once.

1 Like

I did have the same experience as you Dev Patel when using ddg_images, restarted notebook and it worked once.

I am now using search_images_ddg per Kamui’s suggestion and it works for me.

This works for me:

This does not:

1 Like

Yup, its working thanks. :smile: