JorgePoblete / DuckDuckGoImages

Search and download images using DuckDuckGo search engine
MIT License
15 stars 4 forks source link

Any query ends up with: ValueError: not enough values to unpack (expected 2, got 0) #4

Open k-nowicki opened 2 years ago

k-nowicki commented 2 years ago

Seems that Duck changed something, and any query ends up with this error:

import DuckDuckGoImages as ddg ddg.download('kittens')

Traceback (most recent call last): File "", line 1, in File "/home/k/lib/python3.9/site-packages/DuckDuckGoImages.py", line 57, in download urls = get_image_urls(query, license, safe_search) File "/home/k/lib/python3.9/site-packages/DuckDuckGoImages.py", line 106, in get_image_urls return _fetch_search_urls(query, token, license, safe_search) File "/home/k/lib/python3.9/site-packages/DuckDuckGoImages.py", line 136, in _fetch_search_urls _urls, next = _get_urls(f"{URL}i.js", query, what) ValueError: not enough values to unpack (expected 2, got 0)

Version: 2.0.8

jmmb07 commented 2 years ago

I did two things and i'm not sure what worked, but i was able to download images:

In here: https://github.com/JorgePoblete/DuckDuckGoImages/issues/3#issuecomment-1218865679, the owner told the problem was the user agent:

the example is correct, the problem was that the user agent used is outdated and duckduck go blocked the requests, the user agent has been updated in v2.0.8, there the example should work again

So, i opened my Firefox and consulted my user-agent: Captura de tela 2022-10-26 214357

Then, i opened the "DuckDuckGoImages.py" and modify the line 150 with my user-agent: after

The other thing i did was a search on duckduckgo via firefox https://github.com/JorgePoblete/DuckDuckGoImages/issues/3#issuecomment-1246179520:

it seems that duckduckgo has made a change on how it works, for some reason you need to actually made a search on duckduckgo via your browser to made the example and all the other features work for some time, i'll be investigating what was this change to upload a fix, but in the meantine, before running your code, make a search on your browser on duckduckgo.

jsandeo commented 1 year ago

it seems that duckduckgo has made a change on how it works, for some reason you need to actually made a search on duckduckgo via your browser to made the example and all the other features work for some time, i'll be investigating what was this change to upload a fix, but in the meantine, before running your code, make a search on your browser on duckduckgo.

What worked for me was setting my browser's user agent and also using a new IP (in my case that meant rebooting my router, but I guess using a VPN should work).

jorigel commented 1 year ago

Hi, to put it into a lib was a good idea, but I have the same problem. Tried all these things and still don't work! Shows the same error-message ValueError as like @k-nowicki. I'm quiet sure that ddg changed something to complicate auto-download. I see that this issue exists since end of last year.

Is there meanwhile an Update at work? regards jori

w4jbm commented 9 months ago

I've tried and get this same error even after updating the user-agent string.

jorigel commented 9 months ago

Hi, no change from my side either. Posted this problem on diverse pages. The only thing I got was cheap shots but no constructive help . . .

Thiago-FR commented 8 months ago

Hi, same mistake

Code:

import DuckDuckGoImages as ddg
ddg.download('kittens')

Result: ValueError: not enough values to unpack (expected 2, got 0)

satyrmipt commented 2 months ago

Hi, same error

ValueError: not enough values to unpack (expected 2, got 0)