!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){var t=null;try{t=new URLSearchParams(window.location.search).get("docusaurus-theme")}catch(t){}return t}()||function(){var t=null;try{t=localStorage.getItem("theme")}catch(t){}return t}();t(null!==e?e:"light")}(),document.documentElement.setAttribute("data-announcement-bar-initially-dismissed",function(){try{return"true"===localStorage.getItem("docusaurus.announcement.dismiss")}catch(t){}return!1}())

[Skip to main content](#__docusaurus_skipToContent_fallback)

You are viewing the **preview** v0.2 docs. View the **stable** v0.1 docs [here](/v0.1/docs/get_started/introduction/). Leave feedback on the v0.2 docs [here](https://github.com/langchain-ai/langchainjs/discussions/5386).

[

![🦜️🔗 Langchain](/v0.2/img/brand/wordmark.png)![🦜️🔗 Langchain](/v0.2/img/brand/wordmark-dark.png)

](/v0.2/)[Integrations](/v0.2/docs/integrations/platforms/)[API Reference](https://v02.api.js.langchain.com)

[More](#)

*   [People](/v0.2/docs/people/)
*   [Community](/v0.2/docs/community)
*   [Tutorials](/v0.2/docs/additional_resources/tutorials)
*   [Contributing](/v0.2/docs/contributing)

[v0.2](#)

*   [v0.2](/v0.2/docs/introduction)
*   [v0.1](https://js.langchain.com/v0.1/docs/get_started/introduction)

[🦜🔗](#)

*   [LangSmith](https://smith.langchain.com)
*   [LangSmith Docs](https://docs.smith.langchain.com)
*   [LangChain Hub](https://smith.langchain.com/hub)
*   [LangServe](https://github.com/langchain-ai/langserve)
*   [Python Docs](https://python.langchain.com/)

[Chat](https://chatjs.langchain.com)[](https://github.com/langchain-ai/langchainjs)

Search

*   [Providers](/v0.2/docs/integrations/platforms/)
    
    *   [Providers](/v0.2/docs/integrations/platforms/)
    *   [Anthropic](/v0.2/docs/integrations/platforms/anthropic)
    *   [AWS](/v0.2/docs/integrations/platforms/aws)
    *   [Google](/v0.2/docs/integrations/platforms/google)
    *   [Microsoft](/v0.2/docs/integrations/platforms/microsoft)
    *   [OpenAI](/v0.2/docs/integrations/platforms/openai)
*   [Components](/v0.2/docs/integrations/components)
    
    *   [Chat models](/v0.2/docs/integrations/chat/)
        
    *   [LLMs](/v0.2/docs/integrations/llms/)
        
    *   [Embedding models](/v0.2/docs/integrations/text_embedding)
        
    *   [Document loaders](/v0.2/docs/integrations/document_loaders)
        
    *   [Document transformers](/v0.2/docs/integrations/document_transformers)
        
    *   [Vector stores](/v0.2/docs/integrations/vectorstores)
        
    *   [Retrievers](/v0.2/docs/integrations/retrievers)
        
    *   [Tools](/v0.2/docs/integrations/tools)
        
        *   [ChatGPT Plugins](/v0.2/docs/integrations/tools/aiplugin-tool)
        *   [Connery Action Tool](/v0.2/docs/integrations/tools/connery)
        *   [Dall-E Tool](/v0.2/docs/integrations/tools/dalle)
        *   [Discord Tool](/v0.2/docs/integrations/tools/discord)
        *   [DuckDuckGoSearch](/v0.2/docs/integrations/tools/duckduckgo_search)
        *   [Exa Search](/v0.2/docs/integrations/tools/exa_search)
        *   [Gmail Tool](/v0.2/docs/integrations/tools/gmail)
        *   [Google Calendar Tool](/v0.2/docs/integrations/tools/google_calendar)
        *   [Google Places Tool](/v0.2/docs/integrations/tools/google_places)
        *   [Agent with AWS Lambda](/v0.2/docs/integrations/tools/lambda_agent)
        *   [Python interpreter tool](/v0.2/docs/integrations/tools/pyinterpreter)
        *   [SearchApi tool](/v0.2/docs/integrations/tools/searchapi)
        *   [Searxng Search tool](/v0.2/docs/integrations/tools/searxng)
        *   [StackExchange Tool](/v0.2/docs/integrations/tools/stackexchange)
        *   [Tavily Search](/v0.2/docs/integrations/tools/tavily_search)
        *   [Web Browser Tool](/v0.2/docs/integrations/tools/webbrowser)
        *   [Wikipedia tool](/v0.2/docs/integrations/tools/wikipedia)
        *   [WolframAlpha Tool](/v0.2/docs/integrations/tools/wolframalpha)
        *   [Agent with Zapier NLA Integration](/v0.2/docs/integrations/tools/zapier_agent)
    *   [Toolkits](/v0.2/docs/integrations/toolkits)
        
    *   [Stores](/v0.2/docs/integrations/stores/)
        

*   [](/v0.2/)
*   [Components](/v0.2/docs/integrations/components)
*   [Tools](/v0.2/docs/integrations/tools)
*   Web Browser Tool

Web Browser Tool
================

The Webbrowser Tool gives your agent the ability to visit a website and extract information. It is described to the agent as

    useful for when you need to find something on or summarize a webpage. input should be a comma separated list of "valid URL including protocol","what you want to find on the page or empty string for a summary".

It exposes two modes of operation:

*   when called by the Agent with only a URL it produces a summary of the website contents
*   when called by the Agent with a URL and a description of what to find it will instead use an in-memory Vector Store to find the most relevant snippets and summarise those

Setup[​](#setup "Direct link to Setup")
---------------------------------------

To use the Webbrowser Tool you need to install the dependencies:

*   npm
*   Yarn
*   pnpm

    npm install cheerio axios

    yarn add cheerio axios

    pnpm add cheerio axios

Usage, standalone[​](#usage-standalone "Direct link to Usage, standalone")
--------------------------------------------------------------------------

tip

See [this section for general instructions on installing integration packages](/v0.2/docs/how_to/installation#installing-integration-packages).

*   npm
*   Yarn
*   pnpm

    npm install @langchain/openai

    yarn add @langchain/openai

    pnpm add @langchain/openai

    import { WebBrowser } from "langchain/tools/webbrowser";import { ChatOpenAI, OpenAIEmbeddings } from "@langchain/openai";export async function run() {  // this will not work with Azure OpenAI API yet  // Azure OpenAI API does not support embedding with multiple inputs yet  // Too many inputs. The max number of inputs is 1.  We hope to increase the number of inputs per request soon. Please contact us through an Azure support request at: https://go.microsoft.com/fwlink/?linkid=2213926 for further questions.  // So we will fail fast, when Azure OpenAI API is used  if (process.env.AZURE_OPENAI_API_KEY) {    throw new Error(      "Azure OpenAI API does not support embedding with multiple inputs yet"    );  }  const model = new ChatOpenAI({ temperature: 0 });  const embeddings = new OpenAIEmbeddings(    process.env.AZURE_OPENAI_API_KEY      ? { azureOpenAIApiDeploymentName: "Embeddings2" }      : {}  );  const browser = new WebBrowser({ model, embeddings });  const result = await browser.invoke(    `"https://www.themarginalian.org/2015/04/09/find-your-bliss-joseph-campbell-power-of-myth","who is joseph campbell"`  );  console.log(result);  /*  Joseph Campbell was a mythologist and writer who discussed spirituality, psychological archetypes, cultural myths, and the mythology of self. He sat down with Bill Moyers for a lengthy conversation at George Lucas’s Skywalker Ranch in California, which continued the following year at the American Museum of Natural History in New York. The resulting 24 hours of raw footage were edited down to six one-hour episodes and broadcast on PBS in 1988, shortly after Campbell’s death, in what became one of the most popular in the history of public television.  Relevant Links:  - [The Holstee Manifesto](http://holstee.com/manifesto-bp)  - [The Silent Music of the Mind: Remembering Oliver Sacks](https://www.themarginalian.org/2015/08/31/remembering-oliver-sacks)  - [Joseph Campbell series](http://billmoyers.com/spotlight/download-joseph-campbell-and-the-power-of-myth-audio/)  - [Bill Moyers](https://www.themarginalian.org/tag/bill-moyers/)  - [books](https://www.themarginalian.org/tag/books/)  */}

#### API Reference:

*   [WebBrowser](https://v02.api.js.langchain.com/classes/langchain_tools_webbrowser.WebBrowser.html) from `langchain/tools/webbrowser`
*   [ChatOpenAI](https://v02.api.js.langchain.com/classes/langchain_openai.ChatOpenAI.html) from `@langchain/openai`
*   [OpenAIEmbeddings](https://v02.api.js.langchain.com/classes/langchain_openai.OpenAIEmbeddings.html) from `@langchain/openai`

Usage, in an Agent[​](#usage-in-an-agent "Direct link to Usage, in an Agent")
-----------------------------------------------------------------------------

    import { OpenAI, OpenAIEmbeddings } from "@langchain/openai";import { initializeAgentExecutorWithOptions } from "langchain/agents";import { Calculator } from "@langchain/community/tools/calculator";import { WebBrowser } from "langchain/tools/webbrowser";import { SerpAPI } from "@langchain/community/tools/serpapi";export const run = async () => {  const model = new OpenAI({ temperature: 0 });  const embeddings = new OpenAIEmbeddings();  const tools = [    new SerpAPI(process.env.SERPAPI_API_KEY, {      location: "Austin,Texas,United States",      hl: "en",      gl: "us",    }),    new Calculator(),    new WebBrowser({ model, embeddings }),  ];  const executor = await initializeAgentExecutorWithOptions(tools, model, {    agentType: "zero-shot-react-description",    verbose: true,  });  console.log("Loaded agent.");  const input = `What is the word of the day on merriam webster. What is the top result on google for that word`;  console.log(`Executing with input "${input}"...`);  const result = await executor.invoke({ input });  /*  Entering new agent_executor chain...  I need to find the word of the day on Merriam Webster and then search for it on Google  Action: web-browser  Action Input: "https://www.merriam-webster.com/word-of-the-day", ""  Summary: Merriam-Webster is a website that provides users with a variety of resources, including a dictionary, thesaurus, word finder, word of the day, games and quizzes, and more. The website also allows users to log in and save words, view recents, and access their account settings. The Word of the Day for April 14, 2023 is "lackadaisical", which means lacking in life, spirit, or zest. The website also provides quizzes and games to help users build their vocabulary.  Relevant Links:   - [Test Your Vocabulary](https://www.merriam-webster.com/games)  - [Thesaurus](https://www.merriam-webster.com/thesaurus)  - [Word Finder](https://www.merriam-webster.com/wordfinder)  - [Word of the Day](https://www.merriam-webster.com/word-of-the-day)  - [Shop](https://shop.merriam-webster.com/?utm_source=mwsite&utm_medium=nav&utm_content=  I now need to search for the word of the day on Google  Action: search  Action Input: "lackadaisical"  lackadaisical implies a carefree indifference marked by half-hearted efforts. lackadaisical college seniors pretending to study. listless suggests a lack of ...  Finished chain.  */  console.log(`Got output ${JSON.stringify(result, null, 2)}`);  /*  Got output {    "output": "The word of the day on Merriam Webster is \"lackadaisical\", which implies a carefree indifference marked by half-hearted efforts.",    "intermediateSteps": [      {        "action": {          "tool": "web-browser",          "toolInput": "https://www.merriam-webster.com/word-of-the-day\", ",          "log": " I need to find the word of the day on Merriam Webster and then search for it on Google\nAction: web-browser\nAction Input: \"https://www.merriam-webster.com/word-of-the-day\", \"\""        },        "observation": "\n\nSummary: Merriam-Webster is a website that provides users with a variety of resources, including a dictionary, thesaurus, word finder, word of the day, games and quizzes, and more. The website also allows users to log in and save words, view recents, and access their account settings. The Word of the Day for April 14, 2023 is \"lackadaisical\", which means lacking in life, spirit, or zest. The website also provides quizzes and games to help users build their vocabulary.\n\nRelevant Links: \n- [Test Your Vocabulary](https://www.merriam-webster.com/games)\n- [Thesaurus](https://www.merriam-webster.com/thesaurus)\n- [Word Finder](https://www.merriam-webster.com/wordfinder)\n- [Word of the Day](https://www.merriam-webster.com/word-of-the-day)\n- [Shop](https://shop.merriam-webster.com/?utm_source=mwsite&utm_medium=nav&utm_content="      },      {        "action": {          "tool": "search",          "toolInput": "lackadaisical",          "log": " I now need to search for the word of the day on Google\nAction: search\nAction Input: \"lackadaisical\""        },        "observation": "lackadaisical implies a carefree indifference marked by half-hearted efforts. lackadaisical college seniors pretending to study. listless suggests a lack of ..."      }    ]  }  */};

#### API Reference:

*   [OpenAI](https://v02.api.js.langchain.com/classes/langchain_openai.OpenAI.html) from `@langchain/openai`
*   [OpenAIEmbeddings](https://v02.api.js.langchain.com/classes/langchain_openai.OpenAIEmbeddings.html) from `@langchain/openai`
*   [initializeAgentExecutorWithOptions](https://v02.api.js.langchain.com/functions/langchain_agents.initializeAgentExecutorWithOptions.html) from `langchain/agents`
*   [Calculator](https://v02.api.js.langchain.com/classes/langchain_community_tools_calculator.Calculator.html) from `@langchain/community/tools/calculator`
*   [WebBrowser](https://v02.api.js.langchain.com/classes/langchain_tools_webbrowser.WebBrowser.html) from `langchain/tools/webbrowser`
*   [SerpAPI](https://v02.api.js.langchain.com/classes/langchain_community_tools_serpapi.SerpAPI.html) from `@langchain/community/tools/serpapi`

* * *

#### Was this page helpful?

  

#### You can leave detailed feedback [on GitHub](https://github.com/langchain-ai/langchainjs/issues/new?assignees=&labels=03+-+Documentation&projects=&template=documentation.yml&title=DOC%3A+%3CPlease+write+a+comprehensive+title+after+the+%27DOC%3A+%27+prefix%3E).

[

Previous

Tavily Search

](/v0.2/docs/integrations/tools/tavily_search)[

Next

Wikipedia tool

](/v0.2/docs/integrations/tools/wikipedia)

Community

*   [Discord](https://discord.gg/cU2adEyC7w)
*   [Twitter](https://twitter.com/LangChainAI)

GitHub

*   [Python](https://github.com/langchain-ai/langchain)
*   [JS/TS](https://github.com/langchain-ai/langchainjs)

More

*   [Homepage](https://langchain.com)
*   [Blog](https://blog.langchain.dev)

Copyright © 2024 LangChain, Inc.