.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.engines.seekr Namespace Reference

Functions

 init (engine_settings)
 
 request (query, params)
 
 _images_response (json)
 
 _videos_response (json)
 
 _news_response (json)
 
 response (resp)
 

Variables

dict about
 
str base_url = "https://api.seekr.com"
 
bool paging = True
 
str api_key = "srh1-22fb-sekr"
 
str seekr_category = 'unset'
 

Detailed Description

seekr.com Seeker Score

Seekr is a privately held search and content evaluation engine that prioritizes
credibility over popularity.

Configuration
=============

The engine has the following additional settings:

- :py:obj:`seekr_category`
- :py:obj:`api_key`

This implementation is used by seekr engines in the :ref:`settings.yml
<settings engine>`:

.. code:: yaml

  - name: seekr news
    seekr_category: news
    ...
  - name: seekr images
    seekr_category: images
    ...
  - name: seekr videos
    seekr_category: videos
    ...

Known Quirks
============

The implementation to support :py:obj:`paging <searx.enginelib.Engine.paging>`
is based on the *nextpage* method of Seekr's REST API.  This feature is *next
page driven* and plays well with the :ref:`infinite_scroll <settings ui>`
setting in SearXNG but it does not really fit into SearXNG's UI to select a page
by number.

Implementations
===============

Function Documentation

◆ _images_response()

searx.engines.seekr._images_response ( json)
protected

Definition at line 104 of file seekr.py.

104def _images_response(json):
105
106 search_results = json.get('expertResponses')
107 if search_results:
108 search_results = search_results[0].get('advice')
109 else: # response from a 'nextResultSet'
110 search_results = json.get('advice')
111
112 results = []
113 if not search_results:
114 return results
115
116 for result in search_results['results']:
117 summary = loads(result['summary'])
118 results.append(
119 {
120 'template': 'images.html',
121 'url': summary['refererurl'],
122 'title': result['title'],
123 'img_src': result['url'],
124 'resolution': f"{summary['width']}x{summary['height']}",
125 'thumbnail_src': 'https://media.seekr.com/engine/rp/' + summary['tg'] + '/?src= ' + result['thumbnail'],
126 }
127 )
128
129 if search_results.get('nextResultSet'):
130 results.append(
131 {
132 "engine_data": search_results.get('nextResultSet'),
133 "key": "nextpage",
134 }
135 )
136 return results
137
138

Referenced by searx.engines.seekr.response().

+ Here is the caller graph for this function:

◆ _news_response()

searx.engines.seekr._news_response ( json)
protected

Definition at line 172 of file seekr.py.

172def _news_response(json):
173
174 search_results = json.get('expertResponses')
175 if search_results:
176 search_results = search_results[0]['advice']['categorySearchResult']['searchResult']
177 else: # response from a 'nextResultSet'
178 search_results = json.get('advice')
179
180 results = []
181 if not search_results:
182 return results
183
184 for result in search_results['results']:
185
186 results.append(
187 {
188 'url': result['url'],
189 'title': result['title'],
190 'content': result['summary'] or result["topCategory"] or result["displayUrl"] or '',
191 'thumbnail': result.get('thumbnail', ''),
192 'publishedDate': datetime.strptime(result['pubDate'][:19], '%Y-%m-%d %H:%M:%S'),
193 'metadata': gettext("Language") + ': ' + result.get('language', ''),
194 }
195 )
196
197 if search_results.get('nextResultSet'):
198 results.append(
199 {
200 "engine_data": search_results.get('nextResultSet'),
201 "key": "nextpage",
202 }
203 )
204 return results
205
206

Referenced by searx.engines.seekr.response().

+ Here is the caller graph for this function:

◆ _videos_response()

searx.engines.seekr._videos_response ( json)
protected

Definition at line 139 of file seekr.py.

139def _videos_response(json):
140
141 search_results = json.get('expertResponses')
142 if search_results:
143 search_results = search_results[0].get('advice')
144 else: # response from a 'nextResultSet'
145 search_results = json.get('advice')
146
147 results = []
148 if not search_results:
149 return results
150
151 for result in search_results['results']:
152 summary = loads(result['summary'])
153 results.append(
154 {
155 'template': 'videos.html',
156 'url': result['url'],
157 'title': result['title'],
158 'thumbnail': 'https://media.seekr.com/engine/rp/' + summary['tg'] + '/?src= ' + result['thumbnail'],
159 }
160 )
161
162 if search_results.get('nextResultSet'):
163 results.append(
164 {
165 "engine_data": search_results.get('nextResultSet'),
166 "key": "nextpage",
167 }
168 )
169 return results
170
171

Referenced by searx.engines.seekr.response().

+ Here is the caller graph for this function:

◆ init()

searx.engines.seekr.init ( engine_settings)

Definition at line 68 of file seekr.py.

68def init(engine_settings):
69
70 # global paging
71 if engine_settings['seekr_category'] not in ['news', 'videos', 'images']:
72 raise ValueError(f"Unsupported seekr category: {engine_settings['seekr_category']}")
73
74

◆ request()

searx.engines.seekr.request ( query,
params )

Definition at line 75 of file seekr.py.

75def request(query, params):
76
77 if not query:
78 return None
79
80 args = {
81 'query': query,
82 'apiKey': api_key,
83 }
84
85 api_url = base_url + '/engine'
86 if seekr_category == 'news':
87 api_url += '/v2/newssearch'
88
89 elif seekr_category == 'images':
90 api_url += '/imagetab'
91
92 elif seekr_category == 'videos':
93 api_url += '/videotab'
94
95 params['url'] = f"{api_url}?{urlencode(args)}"
96 if params['pageno'] > 1:
97 nextpage = params['engine_data'].get('nextpage')
98 if nextpage:
99 params['url'] = nextpage
100
101 return params
102
103

◆ response()

searx.engines.seekr.response ( resp)

Definition at line 207 of file seekr.py.

207def response(resp):
208 json = resp.json()
209
210 if seekr_category == "videos":
211 return _videos_response(json)
212 if seekr_category == "images":
213 return _images_response(json)
214 if seekr_category == "news":
215 return _news_response(json)
216
217 raise ValueError(f"Unsupported seekr category: {seekr_category}")

References searx.engines.seekr._images_response(), searx.engines.seekr._news_response(), and searx.engines.seekr._videos_response().

+ Here is the call graph for this function:

Variable Documentation

◆ about

dict searx.engines.seekr.about
Initial value:
1= {
2 "website": 'https://seekr.com/',
3 "official_api_documentation": None,
4 "use_official_api": False,
5 "require_api_key": True,
6 "results": 'JSON',
7 "language": 'en',
8}

Definition at line 49 of file seekr.py.

◆ api_key

str searx.engines.seekr.api_key = "srh1-22fb-sekr"

Definition at line 61 of file seekr.py.

◆ base_url

str searx.engines.seekr.base_url = "https://api.seekr.com"

Definition at line 58 of file seekr.py.

◆ paging

bool searx.engines.seekr.paging = True

Definition at line 59 of file seekr.py.

◆ seekr_category

str searx.engines.seekr.seekr_category = 'unset'

Definition at line 64 of file seekr.py.