The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
Web Loader: Add proxy support (#6792)
Tim Asp3ca1a387c258
diff --git a/docs/extras/modules/data_connection/document_loaders/integrations/web_base.ipynb b/docs/extras/modules/data_connection/document_loaders/integrations/web_base.ipynbindex 56b1edb376..5a91c3cd16 100644--- a/docs/extras/modules/data_connection/document_loaders/integrations/web_base.ipynb+++ b/docs/extras/modules/data_connection/document_loaders/integrations/web_base.ipynb@@ -224,13 +224,33 @@"docs"]},+ {+ "cell_type": "markdown",+ "source": [+ "## Using proxies\n",+ "\n",+ "Sometimes you might need to use proxies to get around IP blocks. You can pass in a dictionary of proxies to the loader (and `requests` underneath) to use them."+ ],+ "metadata": {+ "collapsed": false+ }+ },{"cell_type": "code","execution_count": null,- "id": "1dd8ab23",- "metadata": {},"outputs": [],- "source": []+ "source": [+ "loader = WebBaseLoader(\n",+ " \"https://www.walmart.com/search?q=parrots\", proxies={\n",+ " \"http\": \"http://{username}:{password}:@proxy.service.com:6666/\",\n",+ " \"https\": \"https://{username}:{password}:@proxy.service.com:6666/\"\n",+ " }\n",+ ")\n",+ "docs = loader.load()\n"+ ],+ "metadata": {+ "collapsed": false+ }}],"metadata": {diff --git a/langchain/document_loaders/web_base.py b/langchain/document_loaders/web_base.pyindex 6769640605..1528cd6156 100644--- a/langchain/document_loaders/web_base.py+++ b/langchain/document_loaders/web_base.py@@ -61,6 +61,7 @@ class WebBaseLoader(BaseLoader):web_path: Union[str, List[str]],header_template: Optional[dict] = None,verify: Optional[bool] = True,+ proxies: Optional[dict] = None,):"""Initialize with webpage path."""@@ -97,6 +98,9 @@ class WebBaseLoader(BaseLoader):)self.session.headers = dict(headers)+ if proxies:+ self.session.proxies.update(proxies)+@propertydef web_path(self) -> str:if len(self.web_paths) > 1: