diff options
author | H Lohaus <hlohaus@users.noreply.github.com> | 2024-05-18 23:18:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-18 23:18:32 +0200 |
commit | 97ce36a217b7998aee460c62c926c0c1f6f3baf6 (patch) | |
tree | 4a137ca4958a81272e37f952b9330a197038f83f /README.md | |
parent | Merge pull request #1974 from hlohaus/leech (diff) | |
parent | Add get/set cookies dir, hide prompt option in gui (diff) | |
download | gpt4free-0.3.1.5.tar gpt4free-0.3.1.5.tar.gz gpt4free-0.3.1.5.tar.bz2 gpt4free-0.3.1.5.tar.lz gpt4free-0.3.1.5.tar.xz gpt4free-0.3.1.5.tar.zst gpt4free-0.3.1.5.zip |
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 30 |
1 files changed, 25 insertions, 5 deletions
@@ -236,19 +236,39 @@ set_cookies(".google.com", { }) ``` -Alternatively, you can place your .har and cookie files in the `/har_and_cookies` directory. To export a cookie file, use the EditThisCookie extension available on the Chrome Web Store: [EditThisCookie Extension](https://chromewebstore.google.com/detail/editthiscookie/fngmhnnpilhplaeedifhccceomclgfbg). +#### Using .har and Cookie Files -You can also create .har files to capture cookies. If you need further assistance, refer to the next section. +You can place `.har` and cookie files in the default `./har_and_cookies` directory. To export a cookie file, use the [EditThisCookie Extension](https://chromewebstore.google.com/detail/editthiscookie/fngmhnnpilhplaeedifhccceomclgfbg) available on the Chrome Web Store. -```bash -python -m g4f.cli api --debug +#### Creating .har Files to Capture Cookies + +To capture cookies, you can also create `.har` files. For more details, refer to the next section. + +#### Changing the Cookies Directory and Loading Cookie Files in Python + +You can change the cookies directory and load cookie files in your Python environment. To set the cookies directory relative to your Python file, use the following code: + +```python +import os.path +from g4f.cookies import set_cookies_dir, read_cookie_files + +import g4f.debug +g4f.debug.logging = True + +cookies_dir = os.path.join(os.path.dirname(__file__), "har_and_cookies") +set_cookies_dir(cookies_dir) +read_cookie_files(cookies_dir) ``` + +### Debug Mode + +If you enable debug mode, you will see logs similar to the following: + ``` Read .har file: ./har_and_cookies/you.com.har Cookies added: 10 from .you.com Read cookie file: ./har_and_cookies/google.json Cookies added: 16 from .google.com -Starting server... [g4f v-0.0.0] (debug) ``` #### .HAR File for OpenaiChat Provider |