From 3e87b67a3c2b908b80f9a337012aab96dae3c145 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Carlos=20Ferra=20de=20Almeida?= Date: Sun, 28 Jan 2024 00:03:53 +0000 Subject: [PATCH] community[patch]: Add Cookie Support to Fetch Method (#16673) - **Description:** This change allows the `_fetch` method in the `WebBaseLoader` class to utilize cookies from an existing `requests.Session`. It ensures that when the `fetch` method is used, any cookies in the provided session are included in the request. This enhancement maintains compatibility with existing functionality while extending the utility of the `fetch` method for scenarios where cookie persistence is necessary. - **Issue:** Not applicable (new feature), - **Dependencies:** Requires `aiohttp` and `requests` libraries (no new dependencies introduced), - **Twitter handle:** N/A Co-authored-by: Joao Almeida --- libs/community/langchain_community/document_loaders/web_base.py | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/community/langchain_community/document_loaders/web_base.py b/libs/community/langchain_community/document_loaders/web_base.py index 553f9c8e151..daf69b14129 100644 --- a/libs/community/langchain_community/document_loaders/web_base.py +++ b/libs/community/langchain_community/document_loaders/web_base.py @@ -132,6 +132,7 @@ class WebBaseLoader(BaseLoader): url, headers=self.session.headers, ssl=None if self.session.verify else False, + cookies=self.session.cookies.get_dict(), ) as response: return await response.text() except aiohttp.ClientConnectionError as e: