arrrlo / Google-Images-Search

[PYTHON] Search for image using Google Custom Search API and resize & crop afterwards
MIT License
176 stars 34 forks source link

Failed to establish a new connection: [Errno 111] Connection refused #120

Closed ZKukulu closed 2 years ago

ZKukulu commented 2 years ago

Hello, I'm using this as a discord bot command. When trying to only search for images with safe search as 'off', certain keywords like "hentai" or "pornhub" will return this exception error:

Command raised an exception: ConnectionError: HTTPSConnectionPool(host='cdn77-pic.xvideos-cdn.com', port=443): Max retries exceeded with url: /videos/thumbs169poster/52/d9/3a/52d93a87a9df590e9d3c9755fe601b00/52d93a87a9df590e9d3c9755fe601b00.30.jpg (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7faff6fb0d00>: Failed to establish a new connection: [Errno 111] Connection refused'))

I'm not sure if it's related to websites being blocked in my country or not. I'd like a way to simply avoid unreachable websites and skip to the next one.

Thank you in advance.

arrrlo commented 2 years ago

Hi @ZKukulu

The lib was unable to query the URL. Error says it is a SSL error. Unfortunately the lib is not catching this kind of error. I'll implement this.

Cheers.

arrrlo commented 2 years ago

New version is live. Try it out.

If this persist, try avoiding image validation: https://github.com/arrrlo/Google-Images-Search#image-validation

That way every image will pass, but again, you will have problems downloading them. But at least you will have a list of url-s you can that handle on your own to check which image can be downloadable.

ZKukulu commented 2 years ago

Thank you for the fast update! It's working perfectly now without disabling image validation.

I'll let you know if there's anymore issues.