Regarding Bing Custom Search

92 views Asked by At

Since I wanted an application that would act more like a search engine, I have used custom search.ai. However, in the production environment, I see queries and subscription keys, I have to enter. I wish to obtain these codes, so could you please explain how I go about getting them. Your help is greatly appreciated!

1

There are 1 answers

0
user On BEST ANSWER

You can use :

<form method="GET" action="https://www.bing.com" target="_blank">
Search Bing: <input type="text" name="q" placeholder="Search..."/>
<input type="submit" value="Search"/>
</form>


And if you want to do a custom site search then you can use:

var q = document.getElementById("query");
var val= document.getElementById('hidden').value = "+site:reddit.com";
document.getElementById('search').onclick = function() {
    window.location.href='http://bing.com/search?q='+q.value+val;
};

// Submitting value when 'Enter' is pressed
document.addEventListener("keydown", event => {
  if (event.isComposing || event.keyCode !== 13) {
    return;
  }
 window.location.href='http://bing.com/search?q='+q.value+val;
});
<input id="query" type="text" name="q" maxlength="255" placeholder="Search in the site" value="">
<input id="hidden" name="q" type="hidden">
<input id="search" name="q" maxlength="255" placeholder="Search in the site" type="button" value="Search">

You can also use this to open images,videos, etc. directly.