Web Search

Description

The Web Search node performs a web search query and returns the text content of the top results. It scrapes DuckDuckGo's HTML interface, visits each result page, and extracts the readable text using HtmlAgilityPack. It is the primary tool for feeding live, up-to-date information into your AI workflows (research, fact-checking, news aggregation, competitive analysis).

Unlike the basic Web node (which fetches a single known URL), this node takes a search query as input and automatically discovers relevant pages. It handles HTML cleaning, script/style removal, and content truncation to keep the output manageable for downstream AI processing.


Configuration Properties

🔢 Result Count Section

NumericUpDown (default: 3)
The number of search results to visit and extract content from. Each result is concatenated into the final output.

  • 1 = only the top result (fastest, most focused).
  • 3 = good balance between breadth and context usage.
  • 5+ = comprehensive but consumes a lot of tokens; may exceed the context window of small models.

💡 Tip: Start with 1 or 2 results to test your workflow, then increase if you need more diverse sources.


📏 Max Characters Section

NumericUpDown (default: 5000)
The maximum number of characters to extract from each result page. Content beyond this limit is truncated. This is a safety mechanism to prevent a single verbose page from dominating the output and consuming the entire context window.

  • 1000–2000 = short summaries, good for quick overviews.
  • 5000 = balanced default, captures most article bodies.
  • 10000+ = full articles, but be mindful of your Agent's Context Size.

How It Works (Technical Details)

The node performs the following steps internally:

  1. Search: Sends a request to html.duckduckgo.com/html/ with the query.
  2. Headers: Uses a complete set of browser-like headers (User-Agent, Accept, Accept-Language, Sec-Fetch-*) to avoid being blocked with a 403 Forbidden.
  3. Parse Results: Extracts the list of result URLs from the HTML.
  4. Filter Domains: Automatically skips known problematic domains (YouTube, social media sites) whose cookie consent pages are unusable for simple scraping.
  5. Visit Pages: For each result, performs an HTTP GET, cleans the HTML with HtmlAgilityPack (removes <script>, <style>, <noscript>, <header>, <footer>, <nav>), and targets the <body> content.
  6. Truncate: Limits each page to Max Characters.
  7. Concatenate: Joins all results with separators and sends the final text downstream.

Usage Example

"Research a topic before writing":

  1. An Input node receives: "History of the steam engine".
  2. A Web Search node with:
    • Result Count: 3
    • Max Characters: 5000
  3. An Agent node receives the scraped content and writes a summary.
  4. An Output node displays the final article.

"Fact-checking an AI claim":

  1. An Agent generates a claim.
  2. A Template node formats it as a search query.
  3. A Web Search node fetches supporting evidence.
  4. A second Agent compares the claim against the evidence.

⚠️ Pitfalls to Avoid

403 Forbidden errors: DuckDuckGo aggressively blocks automated requests. If the node returns a 403 error, it is usually because the headers are incomplete or the IP is temporarily rate-limited. Wait a few minutes and retry. Do not increase the Result Count excessively, as this triggers rate limits faster.

No Accept-Encoding header: The node intentionally does NOT send an Accept-Encoding header. This avoids a known decompression bug in HttpClient with certain DuckDuckGo responses. If you modify the code, do not add gzip/br encoding unless you handle decompression manually.

Blocked domains: YouTube, Facebook, Twitter, Instagram, and similar sites are hard-coded in the blocklist. Their cookie consent walls make them unusable for simple HTML scraping. If you need content from these platforms, you must use their official APIs or a dedicated node.

Context window explosion: With Result Count = 5 and Max Characters = 5000, the output can reach 25,000 characters. This will exceed the context window of most small local models (e.g., 7B models with 2048–4096 context). Always check the output size with a Counter node before sending it to an Agent.

Slow execution: Each result page requires a separate HTTP request. With Result Count = 5, the node will make at least 6 requests (1 search + 5 pages). On a slow connection, this can take 10–30 seconds. Use a Delay node downstream if you need to pace subsequent requests.

HTML cleaning is imperfect: The HtmlAgilityPack cleaning removes most boilerplate, but some sites use unconventional structures. You may still see navigation links, sidebars, or footer text in the output. Use a Filter node downstream to remove unwanted patterns if needed.

No JavaScript execution: The node only fetches static HTML. It cannot render JavaScript-heavy pages (Single Page Applications, React/Angular sites). If a result page relies on client-side rendering, the extracted content will be empty or minimal.

Rate limiting: DuckDuckGo may temporarily block your IP if you make too many requests in a short time. If you see repeated 403 errors, reduce the Result Count, add a Delay node between searches, or wait a few minutes before retrying.