ostrolucky/Bulk-Bing-Image-downloader

Unable to bulk download from Win10

StoneCypher opened this issue · 6 comments

C:\Users\john\projects\Bulk-Bing-Image-downloader>bbid -o TestRun --limit 5 -s "Happy Clown"
Traceback (most recent call last):
  File "C:\Python310\lib\urllib\request.py", line 1348, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
  File "C:\Python310\lib\http\client.py", line 1276, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "C:\Python310\lib\http\client.py", line 1322, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "C:\Python310\lib\http\client.py", line 1271, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "C:\Python310\lib\http\client.py", line 1031, in _send_output
    self.send(msg)
  File "C:\Python310\lib\http\client.py", line 969, in send
    self.connect()
  File "C:\Python310\lib\http\client.py", line 1448, in connect
    self.sock = self._context.wrap_socket(self.sock,
  File "C:\Python310\lib\ssl.py", line 512, in wrap_socket
    return self.sslsocket_class._create(
  File "C:\Python310\lib\ssl.py", line 1070, in _create
    self.do_handshake()
  File "C:\Python310\lib\ssl.py", line 1341, in do_handshake
    self._sslobj.do_handshake()
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\john\projects\Bulk-Bing-Image-downloader\bbid.py", line 159, in <module>
    fetch_images_from_keyword(pool_sema, img_sema, args.search_string, output_dir, args.filters, args.limit)
  File "C:\Users\john\projects\Bulk-Bing-Image-downloader\bbid.py", line 95, in fetch_images_from_keyword
    response = urllib.request.urlopen(request)
  File "C:\Python310\lib\urllib\request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
  File "C:\Python310\lib\urllib\request.py", line 519, in open
    response = self._open(req, data)
  File "C:\Python310\lib\urllib\request.py", line 536, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
  File "C:\Python310\lib\urllib\request.py", line 496, in _call_chain
    result = func(*args)
  File "C:\Python310\lib\urllib\request.py", line 1391, in https_open
    return self.do_open(http.client.HTTPSConnection, req,
  File "C:\Python310\lib\urllib\request.py", line 1351, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [WinError 10054] An existing connection was forcibly closed by the remote host>

C:\Users\john\projects\Bulk-Bing-Image-downloader>

It's not really clear what's wrong here. I'm able to use Bing Images in a browser. There's no change if I use python to invoke it per directions

Have you tried running it from different network?

I hadn't. I tried just now, switching to an entirely different internet provider.

Same thing.

Bing in the browser works both places.

Only thing remaining is try rebooting the computer, I don't see how else to help unfortunately, it really looks like some issue in your specific instance of OS. BBID was tested on Windows 10.

So I've now tried this on three Windows computers with the same results. Two Win10, one Win11.

I have rebooted the computer.

In looking through StackOverflow, I see that this is the error message that's given when the underlying library isn't set up correctly. Unfortunately, all the common examples seem to be things you've handled already, such as setting a user agent.

Because all three of these machines have the python installation that comes with node, I suspect that the real problem is that the mainline python installation has different network defaults than the one that's installed by node.

Unfortunately, I'm not a python person, so I don't have the ability to debug this.

I hope you'll be open minded and take another look. I think you actually do have a bug, based in assuming that the linux python default configuration is portable, from having used it on one windows machine one place.

At any rate, I switched to another python bing scraper, by gurugaurav, and it works. It's much less convenient than yours, and I'd prefer to switch back if I can, later.

Because all three of these machines have the python installation that comes with node, I suspect that the real problem is that the mainline python installation has different network defaults than the one that's installed by node.

Yeah maybe that's the issue. I've just tried again in Windows 10 where I installed python 3.10.0 by running choco install python and your example command still works. You should also try different python installation. Unfortunately without knowing how to reproduce this issue I can't help. If you figure out some way I can reproduce, let me know.