e04_google_search_with_suggestion#

Feature:

The user types a query and receives a dropdown list of Google search suggestions. The user can then tap “Enter” to perform a Google search in their web browser.

Difficulty: Medium

Dependencies:

pip install requests

Demo: https://asciinema.org/a/616014

class zelfred.gallery.e04_google_search_with_suggestion.Item(title: str, subtitle: Union[str, NoneType] = None, uid: str = <factory>, arg: Union[str, NoneType] = None, autocomplete: Union[str, NoneType] = None, variables: Dict[str, Any] = <factory>)[source]#
enter_handler(ui: UI)[source]#

Open the url in default web browser.

zelfred.gallery.e04_google_search_with_suggestion.encode_query(query: str) str[source]#

Encode the query to be used in the url.

class zelfred.gallery.e04_google_search_with_suggestion.GoogleComplete[source]#

Google complete API caller and parser.

get(query: str) List[str][source]#
Returns:

list of suggestions.

zelfred.gallery.e04_google_search_with_suggestion.handler(query: str, ui: UI)[source]#

The handler is the core of a Zelfred App. It’s a user-defined function that takes the entered query and the UI object as inputs and returns a list of items to render.