Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error while searching with duckduckgo_search #84

Open
adilsonsc opened this issue May 26, 2023 · 5 comments
Open

error while searching with duckduckgo_search #84

adilsonsc opened this issue May 26, 2023 · 5 comments

Comments

@adilsonsc
Copy link

Hi, I'm just beggining the course and I had an issue with the first notebook (Is it a bird?).

When I try run the code, the attempt to make a search with the function search_images returns the following exception:

HTTPError: 403 Client Error: Forbidden for url: https://duckduckgo.com/i.js?l=wt-wt&o=json&s=0&q=bird+photos&vqd=4-117789140384711387116571556492091898243&f=%2C%2C%2C%2C%2C&p=1

I tried to understand the problem and find solution in the forum, but nothing helped.

Please, can you help me?

@poltak
Copy link

poltak commented May 27, 2023

I had this problem too, but managed to solve it after finding this post from the forums:
https://forums.fast.ai/t/duckduckgo-search-not-working/105738/18

It replaces the duckduckgo_search package usage with the function search_images_ddg from fastbook package, which provides the same behavior.

Basically I had to change the pip install -Uqq fastai duckduckgo_search to pip install -Uqq fastai fastbook, to ensure fastbook package is installed. Then in the search_images code block replace the duckduckgo_search usage:

from fastbook import *
from fastcore.all import *

def search_images(term, max_images=30):
    print(f"Searching for '{term}'")
    return search_images_ddg(term, max_images)

It was a bit of a jarring start to the course with the first lesson not working. If this is viewed as an accepted workaround I'd submit a PR

@deedy5
Copy link

deedy5 commented May 30, 2023

just update the package: pip install -U duckduckgo_search

@poltak
Copy link

poltak commented May 30, 2023

@deedy5 the update flag's in the original command (pip install -Uqq fastai duckduckgo_search), but it didn't work for us

@deedy5
Copy link

deedy5 commented May 30, 2023

I updated search_images() to match the latest version of duckduckgo_search and checked on google collab - everything is fine. PR #85

from itertools import islice
from duckduckgo_search import DDGS
from fastcore.all import *

def search_images(term, max_images=200): 
    with DDGS() as ddgs:
        return [x['image'] for x in islice(ddgs.images(term), max_images)]

@poltak
Copy link

poltak commented May 31, 2023

Alright, that solution does work for me on Kaggle too :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants