Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

Exception: Response status code is not 200. Response Status is 404 #230

Closed
EEG20 opened this issue Nov 14, 2023 · 9 comments
Closed

Exception: Response status code is not 200. Response Status is 404 #230

EEG20 opened this issue Nov 14, 2023 · 9 comments
Assignees

Comments

@EEG20
Copy link

EEG20 commented Nov 14, 2023

my code :
from bardapi import Bard

token = '......'
bard = Bard(token=token)
bard.get_answer("hello")['content']

my problem :

Traceback (most recent call last):
File "c:\Users\neveu\OneDrive\Bureau\ay\test.py", line 4, in
bard = Bard(token=token)
File "C:\Users\neveu\AppData\Local\Programs\Python\Python310\lib\site-packages\bardapi\core.py", line 78, in init
self.SNlM0e = self._get_snim0e()
File "C:\Users\neveu\AppData\Local\Programs\Python\Python310\lib\site-packages\bardapi\core.py", line 149, in _get_snim0e
raise Exception(
Exception: Response status code is not 200. Response Status is 404

@EEG20
Copy link
Author

EEG20 commented Nov 14, 2023

i've fixed the problem but i have another problem

code :

from bardapi import Bard
import os

import requests

Get your proxy url at crawlbase https://crawlbase.com/docs/smart-proxy/get/

proxy_url = "[email protected]:8012"
proxies = {"http": proxy_url, "https": proxy_url}
bard = Bard(token='...', proxies=proxies, timeout=30)
bard.get_answer("hello")['content']

problem :
Traceback (most recent call last):
File "C:\Users\neveu\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\connectionpool.py", line 711, in urlopen
self._prepare_proxy(conn)
File "C:\Users\neveu\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\connectionpool.py", line 1007, in prepare_proxy
conn.connect()
File "C:\Users\neveu\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\connection.py", line 419, in connect
self.sock = ssl_wrap_socket(
File "C:\Users\neveu\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\util\ssl
.py", line 449, in ssl_wrap_socket
ssl_sock = ssl_wrap_socket_impl(
File "C:\Users\neveu\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\util\ssl
.py", line 493, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Users\neveu\AppData\Local\Programs\Python\Python310\lib\ssl.py", line 513, in wrap_socket
return self.sslsocket_class._create(
File "C:\Users\neveu\AppData\Local\Programs\Python\Python310\lib\ssl.py", line 1071, in _create
self.do_handshake()
File "C:\Users\neveu\AppData\Local\Programs\Python\Python310\lib\ssl.py", line 1342, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: EE certificate key too weak (_ssl.c:997)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\neveu\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\adapters.py", line 486, in send
resp = conn.urlopen(
File "C:\Users\neveu\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\connectionpool.py", line 798, in urlopen
retries = retries.increment(
File "C:\Users\neveu\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\util\retry.py", line 592, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='bard.google.com', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: EE certificate key too weak (_ssl.c:997)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\Users\neveu\OneDrive\Bureau\ay\test.py", line 10, in
bard = Bard(token='cwi5OPgUf7KEaHnG8v7_CvyITY4GN_u5qumIkZDuEGJrm9vO35j7VRwSW4NhUIwnxMmWjw.', proxies=proxies, timeout=30)
File "C:\Users\neveu\AppData\Local\Programs\Python\Python310\lib\site-packages\bardapi\core.py", line 78, in init
self.SNlM0e = self._get_snim0e()
File "C:\Users\neveu\AppData\Local\Programs\Python\Python310\lib\site-packages\bardapi\core.py", line 145, in _get_snim0e
resp = self.session.get(
File "C:\Users\neveu\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\sessions.py", line 602, in get
return self.request("GET", url, **kwargs)
File "C:\Users\neveu\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\neveu\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\sessions.py", line 703, in send
r = adapter.send(request, **kwargs)
File "C:\Users\neveu\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\adapters.py", line 517, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='bard.google.com', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: EE certificate key too weak (_ssl.c:997)')))

@schneibe
Copy link

how did you fix the "Exception: Response status code is not 200. Response Status is 404"? I am having the same issue

@EEG20
Copy link
Author

EEG20 commented Nov 15, 2023

how did you fix the "Exception: Response status code is not 200. Response Status is 404"? I am having the same issue

The HTTP 404 Not Found response status code indicates that the server cannot find the requested resource. Links that lead to a 404 page are often called broken or dead links and can be subject to link rot. A 404 status code only indicates that the resource is missing: not whether the absence is temporary or permanent.

The HTTP 409 Conflict response status code indicates a request conflict with the current state of the target resource. Conflicts are most likely to occur in response to a PUT request.

It seems there is a conflict with the local resources designated as a proxy server because the local server is unable to act as a proxy. I recommend using an appropriate proxy server.

@useris20x
Copy link

It looks like the problem is in the cookies: __Secure-1PSIDTS and __Secure-1PSIDCC values. It needs for usage and often changes it.

@schneibe
Copy link

This solved my problem (i.e., create a cookie dictionary and add values for __Secure-1PSIDTS and __Secure-1PSIDCC in addition to __Secure-1PSID)

from bardapi import BardCookies

cookie_dict = {
    "__Secure-1PSID": "xxxxxxxxx",
    "__Secure-1PSIDTS": "xxxxxxxxx",
    "__Secure-1PSIDCC":"xxxxxxxxx"
}

bard = BardCookies(cookie_dict=cookie_dict)

print(bard.get_answer("Hello"))

@s11ngh
Copy link

s11ngh commented Nov 18, 2023

This solved my problem (i.e., create a cookie dictionary and add values for __Secure-1PSIDTS and __Secure-1PSIDCC in addition to __Secure-1PSID)

from bardapi import BardCookies

cookie_dict = {
    "__Secure-1PSID": "xxxxxxxxx",
    "__Secure-1PSIDTS": "xxxxxxxxx",
    "__Secure-1PSIDCC":"xxxxxxxxx"
}

bard = BardCookies(cookie_dict=cookie_dict)

print(bard.get_answer("Hello"))

I just tried this but I get an error indicating too many requests:

Exception: Response status code is not 200. Response Status is 429

Any idea how I can get the API working?

@artur-romao
Copy link

This solved my problem (i.e., create a cookie dictionary and add values for __Secure-1PSIDTS and __Secure-1PSIDCC in addition to __Secure-1PSID)

from bardapi import BardCookies

cookie_dict = {
    "__Secure-1PSID": "xxxxxxxxx",
    "__Secure-1PSIDTS": "xxxxxxxxx",
    "__Secure-1PSIDCC":"xxxxxxxxx"
}

bard = BardCookies(cookie_dict=cookie_dict)

print(bard.get_answer("Hello"))

This works, but just temporarily, because __Secure-1PSIDTS and __Secure-1PSIDCC are frequently changing.
You should fetch the cookies every once in a while.

@myreallycoolusername
Copy link

Not sure if this is helpful but I found the thing that gave the 404 error:
`Request sent to https://consent.google.com/m

{
http.fragment: , 
http.method: GET, 
http.query: continue=https://bard.google.com/?hl%3Den&gl=DE&m=0&pc=bard&cm=2&hl=en&src=1, 
http.response.status_code: 404, 
reason: Not Found
}
```

@dsdanielpark
Copy link
Owner

Please referes #112, #229, #248, #259 and FAQ.

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

No branches or pull requests

7 participants