vaibhavk97 / GoBooDo

A Google book downloader with proxy support.
GNU General Public License v3.0
322 stars 60 forks source link

UnboundLocalError: cannot access local variable 'req' where it is not associated with a value #82

Open XodiaXz opened 7 months ago

XodiaXz commented 7 months ago

Hi, I get the following error:

Traceback (most recent call last):
  File "C:\Users\JOSE\Downloads\Compressed\GoBooDo-master\GoBooDo-master\GoBooDo.py", line 50, in resethead
    req = requests.get("https://google."+self.country, cookies={'CONSENT': 'YES+1'}, verify=False)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\JOSE\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\api.py", line 73, in get
    return request("get", url, params=params, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\JOSE\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\JOSE\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\JOSE\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\JOSE\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\adapters.py", line 486, in send
    resp = conn.urlopen(
           ^^^^^^^^^^^^^
  File "C:\Users\JOSE\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\connectionpool.py", line 793, in urlopen
    response = self._make_request(
               ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\JOSE\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\connectionpool.py", line 467, in _make_request
    self._validate_conn(conn)
  File "C:\Users\JOSE\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\connectionpool.py", line 1099, in _validate_conn
    conn.connect()
  File "C:\Users\JOSE\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\connection.py", line 616, in connect
    self.sock = sock = self._new_conn()
                       ^^^^^^^^^^^^^^^^
  File "C:\Users\JOSE\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\connection.py", line 198, in _new_conn
    sock = connection.create_connection(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\JOSE\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\util\connection.py", line 58, in create_connection
    raise LocationParseError(f"'{host}', label empty or too long") from None
urllib3.exceptions.LocationParseError: Failed to parse: 'google..mx', label empty or too long

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\JOSE\Downloads\Compressed\GoBooDo-master\GoBooDo-master\GoBooDo.py", line 216, in <module>
    book = GoBooDo(args.id)
           ^^^^^^^^^^^^^^^^
  File "C:\Users\JOSE\Downloads\Compressed\GoBooDo-master\GoBooDo-master\GoBooDo.py", line 32, in __init__
    self.resethead()
  File "C:\Users\JOSE\Downloads\Compressed\GoBooDo-master\GoBooDo-master\GoBooDo.py", line 61, in resethead
    if 'captcha'.encode() in req.content:
                             ^^^
UnboundLocalError: cannot access local variable 'req' where it is not associated with a value

How can I Fix it?