16

I would like to add simple site search, using Duckduckgo, limited to search only "example.com".

Stackoverflow has solved this, using some JavaScript to add the site:example.com filter to the query.

<form onsubmit="var txt=$(this).find('input[name=\'q\']'); txt.val(txt.val() + ' site:stackoverflow.com');" action="http://www.duckduckgo.com/" method="get" id="duck-duck-go-search">
  <input type="text" value="" maxlength="255" size="36" name="q">&nbsp;
  <input type="submit" value="DuckDuckGo">
 </form>

I'd prefer a solution that does not depend on JavaScript, though.

The URL should be http://duckduckgo.com/?q=site:example.com%20might; the site:example.com must be added to the q= parameter, it seems.

Has anyone found a simple, non JavaScript solution for this?

Community
  • 1
  • 1
berkes
  • 26,996
  • 27
  • 115
  • 206
  • 1
    I tried a simple form POST to see if maybe it would work, but no, same with GET with site as a key. You could always ask for the feature: http://duckduckgo.com/feedback.html – cfeduke Aug 31 '11 at 15:30

1 Answers1

26

I contacted DuckduckGo and got a solution from Weinberg himself.

There actually is a hidden sites param :). Try it! Gabriel, http://ye.gg

It was the plural (not site, but sites) that got me confused, but the solution is very simple:

http://duckduckgo.com/?q=duckduckgo& sites= stackoverflow.com

Or, in a simple HTML form:

<form action="https://duckduckgo.com/" method="get">
  <input type="hidden" name="sites" value="stackoverflow.com">
  <input type="search" name="q">
  <input type="submit" value="Search">
</form>
berkes
  • 26,996
  • 27
  • 115
  • 206
  • Though DuckDuckGo utilises Bing results, it will ignore most of a site's pages, even though Bing as at August 2023 has 100% coverage. For comparison, Google only ever lists 4% of a not-so-popular site. – Patanjali Sep 02 '23 at 16:54