Googler (CLI Google Search) - No results (at all)

Post Reply
Message
Author
User avatar
Fibogacci
Posts: 165
Joined: Sun Dec 30, 2018 4:19 pm

Googler (CLI Google Search) - No results (at all)

#1 Post by Fibogacci »

Hello,

I've found nice program/script for CLI - Googler and installed it.

Unfortunately when I'm trying to search, I only get one message: No results.

I've tested Googler 2.9.0 from MXPI Stable Repo, Googler 3.7.1 from MXPI Debian Backports and 3.8 downloaded directly from:
https://github.com/jarun/googler#downlo ... ingle-file

Minimal requirment for Googler is Python 3.4 (I have 3.5.3 but I've installed additionally 3.7 from MX Test as well).

I've tried Googler on another MX installation (Googler 2.9.0) - the same "No results" message.

Could it be something with Google API as mentioned in Notes, point 2, citatation:
2. Google provides a search API which returns the results in JSON format. However, as per my understanding from the official docs, the API issues the queries against an existing instance of a custom search engine and is limited by 100 search queries per day for free. In addition, I have reservations in paying if they ever change their plan or restrict the API in other ways. So I refrained from coupling with Google plans & policies or exposing my trackable personal custom search API key and identifier for the public. I retained the browser-way of doing it by fetching html, which is a open and free specification.
https://github.com/jarun/googler#notes

Could you install Googler and run it - and can you search through and get any results (others then my 'No results')? Thank you.
MX-18 Continuum x86_64: laptop Dell Inspiron N7110, Intel Core i5-2410M @ 2.900GHz, 4GB RAM, Kernel: 4.19, DE: Xfce

User avatar
Fibogacci
Posts: 165
Joined: Sun Dec 30, 2018 4:19 pm

Re: Googler (CLI Google Search) - No results (at all)

#2 Post by Fibogacci »

Well, I have some new observations about Googler script.

Googler (in MX) works with -N argument - News. It displays ok.

Generally, Googler downloads and creates temporary files in /tmp with HTML code, which can be run/opened eg. in Firefox after changing name/adding .html to the file.

The problem probably could be with parser (I suppose, I don't know for sure), which gets HTML code from temporary file and displays it.

I've installed ddgr (Duck Duck Go search in CLI) through pip3 install and it works ok (it is similar to Googler).

I'm not familiar with Python language, which is probably used for Googler, but I'll continue experiments with that script.

This is the area of script/code, which I think is responsible for my issue:

Code: Select all

@require_keywords
    def fetch(self):
        """Fetch a page and parse for results.
        Results are stored in ``self.results``.
        Raises
        ------
        GoogleConnectionError
        See Also
        --------
        fetch_and_display
        """
        # This method also sets self._results_filtered and
        # self._urltable.
        page = self._conn.fetch_page(self._google_url.relative())

        if logger.isEnabledFor(logging.DEBUG):
            import tempfile
            fd, tmpfile = tempfile.mkstemp(prefix='googler-response-', suffix='.html')
            os.close(fd)
            with open(tmpfile, 'w', encoding='utf-8') as fp:
                fp.write(page)
            logger.debug("Response body written to '%s'.", tmpfile)

        parser = GoogleParser(page, news=self._google_url.news)

        self.results = parser.results
        self._autocorrected = parser.autocorrected
        self._showing_results_for = parser.showing_results_for
        self._results_filtered = parser.filtered
        self._urltable = {}
        for r in self.results:
            self._urltable.update(r.urltable())

    @require_keywords
    def display_results(self, prelude='\n', json_output=False):
        """Display results stored in ``self.results``.
        Parameters
        ----------
        See `fetch_and_display`.
        """
        if json_output:
            # JSON output
            import json
            results_object = [r.jsonizable_object() for r in self.results]
            print(json.dumps(results_object, indent=2, sort_keys=True, ensure_ascii=False))
        else:
            # Regular output
            if not self.results:
                print('No results.', file=sys.stderr)
            else:
                sys.stderr.write(prelude)
                for r in self.results:
r.print()
Maybe you will have some hints, how to solve it. Temporary files are in /tmp (but they have not got .html suffix), and the output is 'No results.'. This is for version 2.7 in MX 16.

For version 2.9 and MX 18 I can't find temporary files.
MX-18 Continuum x86_64: laptop Dell Inspiron N7110, Intel Core i5-2410M @ 2.900GHz, 4GB RAM, Kernel: 4.19, DE: Xfce

User avatar
Stevo
Developer
Posts: 12837
Joined: Fri Dec 15, 2006 8:07 pm

Re: Googler (CLI Google Search) - No results (at all)

#3 Post by Stevo »

You can install the 3.8 deb from Sid safely on MX, but it still shows "no results" with a normal search. I think we need to ask Debian users if they have the same problem.

Post Reply

Return to “Software / Configuration”