Comments (9)
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"))
from bard-api.
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)')))
from bard-api.
how did you fix the "Exception: Response status code is not 200. Response Status is 404"? I am having the same issue
from bard-api.
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.
from bard-api.
It looks like the problem is in the cookies: __Secure-1PSIDTS and __Secure-1PSIDCC values. It needs for usage and often changes it.
from bard-api.
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?
from bard-api.
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.
from bard-api.
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
}
```
from bard-api.
Please referes #112, #229, #248, #259 and FAQ.
from bard-api.
Related Issues (20)
- ChatBard: token_from_browser HOT 9
- ImportError: cannot import name 'BardCookies' from partially initialized module 'bardapi' (most likely due to a circular import) HOT 6
- Some code errors in README examples , os module import HOT 4
- Bard __SECURE-1PSID does not match HOT 2
- Exception: SNlM0e value not found. Double-check __Secure-1PSID value or pass it as Bard(token='xxxxx') HOT 1
- Google changed the the way "__Secure-1PSID" looks, how to use this package effectively,the cookie values does not end in '.' period now HOT 8
- Multiple-Cookies has been changed. HOT 15
- Image generation HOT 4
- Google renames its chatbot Bard to Gemini HOT 41
- Gemini Ultra? HOT 4
- TooManyRedirects: Exceeded 30 redirects. HOT 1
- Check out this Bard/Gemini project. HOT 2
- Google changed their __Secure-1PSID value stracture HOT 2
- ask_about_image Not working HOT 2
- Cookies refreshing very often and getting 429 all the time HOT 2
- How can automaticly get cookies value in no gui servers? HOT 2
- Please, go to Gemini-API `https://github.com/dsdanielpark/Gemini-API`
- a conversation towards getting advance AI HOT 1
- Reflection on the Bard API Project
- Connecting Geminei to Ads HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bard-api.