Google search API multiple input in oneself

1

I'm trying to make different inputs generate a Google search, but Google only creates an input but I can not edit it.

Code Javascript :

(function() {
var cx = '010966112395912926010:u_3n5cqxw50';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
    '//cse.google.com/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();

Code HTML :

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="google.js"></script>
<title></title>
</head>
<body>

The inputs are going to be created by me.

For example:

  • Input 1: intext:"guerra mundial"
  • Input 2: filetype:ppt
  • Input 3: intitle:"historia"

And then generate a search in the following way in Google, concatenating everything:

intext:"guerra mundial" filetype:ppt intitle:"historia"
    
asked by Eduardo Lynch Araya 17.01.2016 в 19:43
source

1 answer

2

To implement a separate search results page, paste the following snippet of code into your results page:

<script>
(function() {
  var cx = 'YOUR_ENGINE_ID';
  var gcse = document.createElement('script');
  gcse.type = 'text/javascript';
  gcse.async = true;
  gcse.src = 'https://cse.google.com/cse.js?cx=' + cx;
  var s = document.getElementsByTagName('script')[0];
 s.parentNode.insertBefore(gcse, s);
})();
</script>
<gcse:searchresults-only></gcse:searchresults-only>

Now you can run the search on the page by passing the "q" parameter in the URL

http://my-results-page-url.com/?q=MisParametrosABuscar 

Give a q = MyParameter ABouse in the address bar. This causes the element to know about the result of the query to be displayed.

What you should do is concatenate the input and send the query to the url.

Successes with development and blessings.

    
answered by 18.01.2016 / 23:22
source