|
pycrossword
0.4
Pure-Python implementation of a crossword puzzle generator and editor
|
Google search interface. More...
Public Member Functions | |
| def | __init__ (self, settings, search_phrase='', exact_match=False, file_types=None, lang=None, country=None, interface_lang=None, link_site=None, related_site=None, in_site=None, nresults=-1, safe_search=False, timeout=5000) |
| def | init (self, search_phrase='', exact_match=False, file_types=None, lang=None, country=None, interface_lang=None, link_site=None, related_site=None, in_site=None, nresults=-1, safe_search=False, timeout=5000) |
| Initializes members with params passed to constructor. More... | |
| def | encode_search (self) |
| Constructs a search query string from the member parameters. More... | |
| def | decode_result (self, txt) |
| Decodes an URL-encoded string (e.g. More... | |
| def | search (self, method='json') |
Returns full Google search results for GoogleSearch::search_phrase. More... | |
| def | search_lite (self) |
Retrieves search results for GoogleSearch::search_phrase as a list. More... | |
Static Public Member Functions | |
| def | get_interface_languages () |
| def | get_document_languages () |
| def | get_document_countries () |
| def | get_user_countries () |
Public Attributes | |
| settings | |
dict stored pointer to app global settings More... | |
| search_phrase | |
str search phrase to search in Google More... | |
| exact_match | |
bool whether to treat the search phrase verbatim More... | |
| file_types | |
iterable file types (extensions) to include in search results More... | |
| lang | |
iterable search documents restricted only to these languages More... | |
| country | |
iterable only return documents found in these countries More... | |
| interface_lang | |
iterable search using only selected interface languages More... | |
| link_site | |
str link site URL More... | |
| related_site | |
str related (parent) site URL More... | |
| in_site | |
str URL of a website to search in More... | |
| nresults | |
int limit number of returned results (-1 = no limit) More... | |
| safe_search | |
bool turn on Google safe search filter More... | |
| timeout | |
int network request timeout (in msec.) More... | |
Google search interface.
Executes search with custom parameters using Google's JSON (REST) API and returns the results in a Python dictionary.
| def pycross.utils.onlineservices.GoogleSearch.__init__ | ( | self, | |
| settings, | |||
search_phrase = '', |
|||
exact_match = False, |
|||
file_types = None, |
|||
lang = None, |
|||
country = None, |
|||
interface_lang = None, |
|||
link_site = None, |
|||
related_site = None, |
|||
in_site = None, |
|||
nresults = -1, |
|||
safe_search = False, |
|||
timeout = 5000 |
|||
| ) |
| settings | dict pointer to the app settings dictionary (pycross::guisettings::CWSettings::settings) |
| search_phrase | str search phrase to search in Google |
| exact_match | bool whether to treat the search phrase verbatim (True) or fuzzily (False) |
| file_types | iterable | None if not None, Google will present results (documents) only having the indicated file types (extensions), e.g. ‘['pdf’, 'doc', 'docx'] @param langiterable|None` search documents restricted only to these languages, as listed by GoogleSearch::get_document_languages() |
| country | iterable | None only return documents found in these countries, as listed by GoogleSearch::get_document_countries() |
| interface_lang | iterable | None search using only selected interface languages, as listed by GoogleSearch::get_interface_languages() |
| link_site | str | None link site URL |
| related_site | str | None related (parent) site URL |
| in_site | str | None URL of a website to search in |
| nresults | int limit number of returned results (-1 = no limit) |
| safe_search | bool turn on Google safe search filter |
| timeout | int network request timeout (in msec.) |
| def pycross.utils.onlineservices.GoogleSearch.decode_result | ( | self, | |
| txt | |||
| ) |
Decodes an URL-encoded string (e.g.
converts '%20' to spaces etc.)
| text | str URL-encoded text |
str decoded text | def pycross.utils.onlineservices.GoogleSearch.encode_search | ( | self | ) |
Constructs a search query string from the member parameters.
str parametrized search URL
|
static |
list list of Google result countries
|
static |
list list of Google document languages
|
static |
list list of Google interface languages
|
static |
list list of Google search countries | def pycross.utils.onlineservices.GoogleSearch.init | ( | self, | |
search_phrase = '', |
|||
exact_match = False, |
|||
file_types = None, |
|||
lang = None, |
|||
country = None, |
|||
interface_lang = None, |
|||
link_site = None, |
|||
related_site = None, |
|||
in_site = None, |
|||
nresults = -1, |
|||
safe_search = False, |
|||
timeout = 5000 |
|||
| ) |
Initializes members with params passed to constructor.
| search_phrase | str search phrase to search in Google |
| exact_match | bool whether to treat the search phrase verbatim (True) or fuzzily (False) |
| file_types | iterable | None if not None, Google will present results (documents) only having the indicated file types (extensions), e.g. ‘['pdf’, 'doc', 'docx'] @param langiterable|None` search documents restricted only to these languages, as listed by GoogleSearch::get_document_languages() |
| country | iterable | None only return documents found in these countries, as listed by GoogleSearch::get_document_countries() |
| interface_lang | iterable | None search using only selected interface languages, as listed by GoogleSearch::get_interface_languages() |
| link_site | str | None link site URL |
| related_site | str | None related (parent) site URL |
| in_site | str | None URL of a website to search in |
| nresults | int limit number of returned results (-1 = no limit) |
| safe_search | bool turn on Google safe search filter |
| timeout | int network request timeout (in msec.) |
| def pycross.utils.onlineservices.GoogleSearch.search | ( | self, | |
method = 'json' |
|||
| ) |
Returns full Google search results for GoogleSearch::search_phrase.
| method | str parsing method to parse the results |
dict | str search results; if method == 'json' (default), the results are parsed as a JSON-formatted string into a Python dictionary object. Otherwise, the raw result string is returned. | def pycross.utils.onlineservices.GoogleSearch.search_lite | ( | self | ) |
Retrieves search results for GoogleSearch::search_phrase as a list.
list search results as a list of dict objects: Retrieves search results for 'self.search_phrase' as a list in the following format:
[{'url': 'URL', 'title': 'TITLE', 'summary': 'SNIPPET'}, ...]
See https://developers.google.com/custom-search/v1/cse/list
| pycross.utils.onlineservices.GoogleSearch.country |
iterable only return documents found in these countries
| pycross.utils.onlineservices.GoogleSearch.exact_match |
bool whether to treat the search phrase verbatim
| pycross.utils.onlineservices.GoogleSearch.file_types |
iterable file types (extensions) to include in search results
| pycross.utils.onlineservices.GoogleSearch.in_site |
str URL of a website to search in
| pycross.utils.onlineservices.GoogleSearch.interface_lang |
iterable search using only selected interface languages
| pycross.utils.onlineservices.GoogleSearch.lang |
iterable search documents restricted only to these languages
| pycross.utils.onlineservices.GoogleSearch.link_site |
str link site URL
| pycross.utils.onlineservices.GoogleSearch.nresults |
int limit number of returned results (-1 = no limit)
| pycross.utils.onlineservices.GoogleSearch.related_site |
str related (parent) site URL
| pycross.utils.onlineservices.GoogleSearch.safe_search |
bool turn on Google safe search filter
| pycross.utils.onlineservices.GoogleSearch.search_phrase |
str search phrase to search in Google
| pycross.utils.onlineservices.GoogleSearch.settings |
dict stored pointer to app global settings
| pycross.utils.onlineservices.GoogleSearch.timeout |
int network request timeout (in msec.)
1.8.17