returns partial HTML results, suitable for
 AJAX to insert into DOM.
 arguments for engine.search are taken from URI request params, whitelisted
541777
def search
      engine  =  BentoSearch.get_engine(params[:engine_id])
      # put it in an iVar mainly for testing purposes.
      @engine = engine


      unless engine.configuration.allow_routable_results == true
        raise AccessDenied.new("engine needs to be registered with :allow_routable_results => true")
      end

      @results         = engine.search safe_search_args(engine, params)
      # template name of a partial with 'yield' to use to wrap the results
      @partial_wrapper = @results.display_configuration.lookup!("ajax.wrapper_template")

      # partial HTML results
      render "bento_search/search/search", :layout => false

    end
67491
def html(self, selector):
        

        result = self.__bs4.select(selector)

        return [str(r) for r in result] \
            if result.__len__() > 1 else \
            str(result[0]) if result.__len__() > 0 else None
1210843
private String submitJS() {

        StringBuffer result = new StringBuffer();
        result.append("  function validateQuery() {\n");
        result.append("    var searchform = document.getElementById(\"EDITOR\");\n");
        result.append("    var query = searchform.elements['query.0'].value;\n");
        result.append("    searchform.elements['query.0'].value = query;\n");
        result.append("    return true;\n");
        result.append("  }\n");
        return result.toString();
    }
1115707
function searchBar_checkSearchResultPage(searchTerm) {
    // Retrieve the URL which is used for the currently selected search engine
    var targetUrl = this._bss.currentEngine.getSubmission(searchTerm, null).uri;
    var currentUrl = this._controller.tabs.activeTabWindow.document.location.href;

    // Check if pure domain names are identical
    var domainName = targetUrl.host.replace(/.+\.(\w+)\.\w+$/gi, "$1");
    var index = currentUrl.indexOf(domainName);

    this._controller.assertJS("subject.URLContainsDomain == true",
                              {URLContainsDomain: currentUrl.indexOf(domainName) != -1});

    // Check if search term is listed in URL
    this._controller.assertJS("subject.URLContainsText == true",
                              {URLContainsText: currentUrl.toLowerCase().indexOf(searchTerm.toLowerCase()) != -1});
  }
894007
def get(self, request, *args, **kwargs):
        
        #noinspection PyAttributeOutsideInit
        self.object_list    = self.get_queryset()
        context             = self.get_context_data(force_search=True)

        if self.form_class:
            context.update({'form': self.get_form()})

        if 'q' in request.GET or 'p' in request.GET:
            return render(
                request,
                '{0}/results.html'.format(self.template_dir),
                context
            )
        else:
            return render_modal_workflow(
                request,
                '{0}/chooser.html'.format(self.template_dir),
                '{0}/chooser.js'.format(self.template_dir),
                context
            )
664809
def _process(self, responses):
        
        self.log.debug("Processing search results")
        items = list()
        for response in responses:
            try:
                soup = BeautifulSoup(response.content, 'html.parser',
                                     from_encoding="iso-8859-1")
            except:
                continue
            else:
                listings = soup.findAll('li', {'class': 'b_algo'})
                items.extend([l.find('a')['href'] for l in listings])
        self.log.debug("Search result URLs were extracted")
        return items
1241595
def get_html(url,
             headers=None,
             timeout=None,
             errors="strict",
             wait_time=None,
             driver=None,
             zillow_only=False,
             cache_only=False,
             zillow_first=False,
             cache_first=False,
             random=False,
             **kwargs):
    
    if wait_time is None:
        wait_time = Config.Crawler.wait_time

    # prepare url
    cache_url1 = prefix + url + "/"
    cache_url2 = prefix + url
    zillow_url = url

    only_flags = [zillow_only, cache_only]
    if sum(only_flags) == 0:
        first_flags = [zillow_first, cache_first]
        if sum(first_flags) == 0:
            if random:
                if randint(0, 1):
                    all_url = [zillow_url, cache_url1, cache_url2]
                else:
                    all_url = [cache_url1, cache_url2, zillow_url]
            else:
                all_url = [zillow_url, cache_url1, cache_url2]
        elif sum(first_flags) == 1:
            if zillow_first:
                all_url = [zillow_url, cache_url1, cache_url2]
            elif cache_first:
                all_url = [cache_url1, cache_url2, zillow_url]
        else:
            raise ValueError(
                "Only zero or one `xxx_first` argument could be `True`!")

    elif sum(only_flags) == 1:
        if zillow_only:
            all_url = [zillow_url, ]
        elif cache_only:
            all_url = [cache_url1, cache_url2]

    else:
        raise ValueError(
            "Only zero or one `xxx_only` argument could be `True`!")

    for url in all_url:
        try:
            html = _get_html(url, headers, timeout, errors,
                             wait_time, driver, **kwargs)
            return html
        except Exception as e:
            pass
    raise e
1355709
def _filter_dom(dom, filters, last_find_all=False):
        
        if isinstance(dom, string_types):
            dom = BeautifulSoup(dom, 'html.parser')
        for idx, find in enumerate(filters, start=1):
            if not dom:
                break
            name, attrs = find.get('name'), find.get('attrs', {})
            if len(filters) == idx and last_find_all:
                dom = dom.find_all(name, attrs=attrs) if name else dom.find_all(attrs=attrs)
            else:
                dom = dom.find(name, attrs=attrs) if name else dom.find(attrs=attrs)
        return dom
402896
function run_search(query) {
      	 var cache_key = query + computeURL();
          //var cached_results = cache.get(cache_key);
          /*if (cached_results) {
              if ($.isFunction($(input).data("settings").onCachedResult)) {
                cached_results = $(input).data("settings").onCachedResult.call(hidden_input, cached_results);
              }
              populate_dropdown(query, cached_results);
          } else {*/
              // Are we doing an ajax search or local data search?
              if($(input).data("settings").url) {
                  var url = computeURL();
                  // Extract existing get params
                  var ajax_params = {};
                  ajax_params.data = {};
                  if(url.indexOf("?") > -1) {
                      var parts = url.split("?");
                      ajax_params.url = parts[0];

                      var param_array = parts[1].split("&");
                      $.each(param_array, function (index, value) {
                          var kv = value.split("=");
                          ajax_params.data[kv[0]] = kv[1];
                      });
                  } else {
                      ajax_params.url = url;
                  }

                  // Prepare the request
                  ajax_params.data[$(input).data("settings").queryParam] = query;
                  ajax_params.type = $(input).data("settings").method;
                  ajax_params.dataType = $(input).data("settings").contentType;
                  if ($(input).data("settings").crossDomain) {
                      ajax_params.dataType = "jsonp";
                  }

                  // exclude current tokens?
                  // send exclude list to the server, so it can also exclude existing tokens
                  if ($(input).data("settings").excludeCurrent) {
                      var currentTokens = $(input).data("tokenInputObject").getTokens();
                      var tokenList = $.map(currentTokens, function (el) {
                          if(typeof $(input).data("settings").tokenValue == 'function')
                              return $(input).data("settings").tokenValue.call(this, el);

                          return el[$(input).data("settings").tokenValue];
                      });

                      ajax_params.data[$(input).data("settings").excludeCurrentParameter] = tokenList.join($(input).data("settings").tokenDelimiter);
                  }

                  // Attach the success callback
                  ajax_params.success = function(results) {
                    cache.add(cache_key, $(input).data("settings").jsonContainer ? results[$(input).data("settings").jsonContainer] : results);
                    if($.isFunction($(input).data("settings").onResult)) {
                        results = $(input).data("settings").onResult.call(hidden_input, results);
                    }

                    // only populate the dropdown if the results are associated with the active search query
                    if(input_box.val() === query) {
                        populate_dropdown(query, $(input).data("settings").jsonContainer ? results[$(input).data("settings").jsonContainer] : results);
                    }
                  };

                  // Provide a beforeSend callback
                  if (settings.onSend) {
                    settings.onSend(ajax_params);
                  }

                  // Make the request
                  $.ajax(ajax_params);
              } else if($(input).data("settings").local_data) {
                  // Do the search through local data
                 var results = $.grep($(input).data("settings").local_data, function (row) {
                      return row[$(input).data("settings").propertyToSearch].toLowerCase().indexOf(query.toLowerCase()) > -1;
                  });

                  cache.add(cache_key, results);
                  if($.isFunction($(input).data("settings").onResult)) {
                      results = $(input).data("settings").onResult.call(hidden_input, results);
                  }
                  populate_dropdown(query, results);
              }
          //}
      }
746095
function retrieveByURI(uri, callback) {
  var query = {
    query: {
      term: {
        uri : uri
      }
    }
  };
  getEs().search({ _index : GLOBAL.config.ESEARCH._index, _type : 'contentItem'}, query, function(err, res) {
    if (!err && res && res.hits.total) {
      if (res.hits.total > 1) {
        // That would be weird.
        throw new Error('more than one result for', uri);
      }
      res = res.hits.hits[0];
    }
    callback(err, res);
  });
}
1021122
def get_html(self,
                 url,
                 params=None,
                 cache_cb=None,
                 decoder_encoding=None,
                 decoder_errors=url_specified_decoder.ErrorsHandle.strict,
                 **kwargs):
        
        response = self.get(
            url=url,
            params=params,
            cache_cb=cache_cb,
            **kwargs
        )
        return url_specified_decoder.decode(
            binary=response.content,
            url=response.url,
            encoding=decoder_encoding,
            errors=decoder_errors,
        )
517926
def get_search_results(portal_type=None, uid=None, **kw):
    

    # If we have an UID, return the object immediately
    if uid is not None:
        logger.info("UID '%s' found, returning the object immediately" % uid)
        return u.to_list(get_object_by_uid(uid))

    # allow to search search for the Plone Site with portal_type
    include_portal = False
    if u.to_string(portal_type) == "Plone Site":
        include_portal = True

    # The request may contain a list of portal_types, e.g.
    # `?portal_type=Document&portal_type=Plone Site`
    if "Plone Site" in u.to_list(req.get("portal_type")):
        include_portal = True

    # Build and execute a catalog query
    results = search(portal_type=portal_type, uid=uid, **kw)

    if include_portal:
        results = list(results) + u.to_list(get_portal())

    return results
1365461
function() {
            this.xhr = $.ajax(_.extend({}, {
                "type":     this.options.method,
                "url":      this.options.url,
                "data":     this.options.params,
                "dataType": this.options.dataType,
                "context":  this,
                "success":  function(data) {
                    logging.debug("Result for request ", this.options);
                    this.trigger("done", data);
                },
                "error": function(xhr, textStatus, errorThrown) {
                    logging.error("Error for request ", this.options);
                    this.trigger("error", {
                        'status': textStatus,
                        'error': errorThrown,
                        'content': xhr.responseText,
                        'xhr': xhr
                    });
                }
            }, this.options.options));
            return this;
        }
818135
@Override
	public void search(
		String[] words,
		WebSiteRequest req,
		HttpServletResponse response,
		List<SearchResult> results,
		AoByteArrayOutputStream bytes,
		List<WebPage> finishedPages
	) {
	}
766451
function (url, async) {
            var suffix = url.match(/\.[\w\d]+$/),
                type,
                // If we are reading a script element for the content of the template,
                // `el` will be set to that script element.
                el,
                // A unique identifier for the view (used for caching).
                // This is typically derived from the element id or
                // the url for the template.
                id,
                // The ajax request used to retrieve the template content.
                jqXHR;

            //If the url has a #, we assume we want to use an inline template
            //from a script element and not current page's HTML
            if (url.match(/^#/)) {
                url = url.substr(1);
            }
            // If we have an inline template, derive the suffix from the `text/???` part.
            // This only supports `<script>` tags.
            if (el = document.getElementById(url)) {
                suffix = "." + el.type.match(/\/(x\-)?(.+)/)[2];
            }

            // If there is no suffix, add one.
            if (!suffix && !$view.cached[url]) {
                url += (suffix = $view.ext);
            }

            if (can.isArray(suffix)) {
                suffix = suffix[0]
            }

            // Convert to a unique and valid id.
            id = $view.toId(url);

            // If an absolute path, use `steal` to get it.
            // You should only be using `//` if you are using `steal`.
            if (url.match(/^\/\//)) {
                var sub = url.substr(2);
                url = !window.steal ? sub : steal.config().root.mapJoin(sub);
            }

            // Set the template engine type.
            type = $view.types[suffix];

            // If it is cached,
            if ($view.cached[id]) {
                // Return the cached deferred renderer.
                return $view.cached[id];

                // Otherwise if we are getting this from a `<script>` element.
            } else if (el) {
                // Resolve immediately with the element's `innerHTML`.
                return $view.registerView(id, el.innerHTML, type);
            } else {
                // Make an ajax request for text.
                var d = new can.Deferred();
                can.ajax({
                    async: async,
                    url: url,
                    dataType: "text",
                    error: function (jqXHR) {
                        checkText("", url);
                        d.reject(jqXHR);
                    },
                    success: function (text) {
                        // Make sure we got some text back.
                        checkText(text, url);
                        $view.registerView(id, text, type, d)
                    }
                });
                return d;
            }
        }
558243
def raw_content(self, output=None, str_output=None):
        """"""
        return self._search_page(output, str_output, self.response.data, lambda regex, content: regex.search(content.decode()))
81308
def search_by(url=None, file=None):
    

    image_url = url
    # image_file = file

    """
    Search result page
    """

    result_url = GOOGLE_SEARCH_BY_ENDPOINT + image_url

    referer = 'http://www.google.com/imghp'
    result_html = fire_request(result_url, referer)

    result = SBIResult()
    result.result_page = result_url
    result.best_guess = extract_best_guess(result_html)

    soup = cook_soup(result_html)

    all_sizes_a_tag = soup.find('a', text='All sizes')

    # No other sizes of this image found
    if not all_sizes_a_tag:
        return result

    all_sizes_href = all_sizes_a_tag['href']
    all_sizes_url = urlparse.urljoin(GOOGLE_BASE_URL, all_sizes_href)

    result.all_sizes_page = all_sizes_url

    """
    All sizes page
    """

    all_sizes_html = fire_request(all_sizes_url, referer=all_sizes_url)

    soup = cook_soup(all_sizes_html)

    img_links =  soup.find_all('a', {'class': 'rg_l'})
    images = []
    for a in img_links:
        url = a['href']
        parse_result = urlparse.urlparse(url)

        querystring = parse_result.query
        querystring_dict = urlparse.parse_qs(querystring)

        image = {}
        image['url'] = querystring_dict['imgurl'][0]
        image['width'] = int(querystring_dict['w'][0])
        image['height'] = int(querystring_dict['h'][0])

        images.append(image)

    result.images = images

    return result