web-search-fetch-tools
Mastering Web Search and Fetch Tools for Research in OpenClaw
When working with OpenClaw, one of the most powerful capabilities at your disposal is the ability to conduct research and gather information from the web efficiently. This is made possible through two essential tools: web_search and web_fetch. These tools allow you to pull in external data, verify facts, and enrich your workflows without leaving the command line. In this article, we'll explore how to use both tools to their full potential.
Understanding web_search and web_fetch
web_search and web_fetch are designed to serve different purposes in your research workflow.
web_searchis your go-to tool for finding up-to-date information from the web. It uses the Brave Search API by default to return structured results, including titles, URLs, and snippets. This makes it ideal for quickly identifying relevant resources on any topic.web_fetch, on the other hand, focuses on extracting readable content from specific web pages. It fetches a URL and converts HTML into clean markdown or text, stripping away clutter and leaving you with the core content.
Together, these tools enable a seamless flow from discovery (web_search) to deep reading (web_fetch).
Using web_search for Discovery
To begin your research, use web_search to query the web. For example:
await web_search({
query: "OpenClaw tutorial",
count: 5,
country: "US",
search_lang: "en",
});
This command returns the top five results for "OpenClaw tutorial" in English from the United States. You can adjust the count parameter to get more or fewer results, and use country and search_lang to target specific regions and languages.
If you're interested in recent developments, add the freshness parameter:
await web_search({
query: "OpenClaw updates",
freshness: "pw", // past week
});
This limits results to those discovered within the past week, ensuring you're working with timely information.
Leveraging web_fetch for Deep Content Extraction
Once you've identified a promising resource through web_search, use web_fetch to pull in the full content. For instance:
await web_fetch({
url: "https://docs.openclaw.ai/tools/web.md",
extractMode: "markdown",
maxChars: 50000,
});
This command retrieves the content of the specified URL and converts it into markdown format, truncating the output to 50,000 characters if necessary. The result is clean, readable text that you can process further or save for later reference.
Practical Applications
These tools are not just for manual exploration—they can be integrated into automated workflows. For example, you might use web_search to monitor for new articles on a specific topic, then automatically fetch and summarize them using web_fetch and a language model.
A common use case is maintaining a personal knowledge base. By periodically searching for updates on topics of interest and fetching relevant articles, you can keep your information current without manual effort.
Best Practices
- Always verify the sources returned by
web_searchbefore relying on them. While the tool provides helpful snippets, it's up to you to assess the credibility of each result. - Use
web_fetchwithmaxCharsto avoid overwhelming your context window. If a page is particularly long, consider breaking it into sections or focusing on key parts. - Combine
web_searchandweb_fetchwith other tools likemessageorwriteto create enriched outputs, such as reports or summaries.
Conclusion
The web_search and web_fetch tools are indispensable for any OpenClaw user looking to conduct thorough research. By mastering these tools, you can efficiently gather, extract, and utilize web-based information, enhancing both your productivity and the quality of your work. Whether you're exploring new topics or staying up to date with the latest developments, these tools provide the foundation for informed decision-making.
Enjoyed this article?
Join the ClawMakers community to discuss this and more with fellow builders.
Join on Skool — It's Free →