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

Functions

 clean_url (url)
 
 request (query, params)
 
 response (resp)
 

Variables

dict about
 
str base_url = 'https://unsplash.com/'
 
str search_url = base_url + 'napi/search/photos?'
 
list categories = ['images']
 
int page_size = 20
 
bool paging = True
 

Detailed Description

Unsplash

Function Documentation

◆ clean_url()

searx.engines.unsplash.clean_url ( url)

Definition at line 26 of file unsplash.py.

26def clean_url(url):
27 parsed = urlparse(url)
28 query = [(k, v) for (k, v) in parse_qsl(parsed.query) if k not in ['ixid', 's']]
29
30 return urlunparse((parsed.scheme, parsed.netloc, parsed.path, parsed.params, urlencode(query), parsed.fragment))
31
32

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

+ Here is the caller graph for this function:

◆ request()

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

Definition at line 33 of file unsplash.py.

33def request(query, params):
34 params['url'] = search_url + urlencode({'query': query, 'page': params['pageno'], 'per_page': page_size})
35 logger.debug("query_url --> %s", params['url'])
36 return params
37
38

◆ response()

searx.engines.unsplash.response ( resp)

Definition at line 39 of file unsplash.py.

39def response(resp):
40 results = []
41 json_data = loads(resp.text)
42
43 if 'results' in json_data:
44 for result in json_data['results']:
45 results.append(
46 {
47 'template': 'images.html',
48 'url': clean_url(result['links']['html']),
49 'thumbnail_src': clean_url(result['urls']['thumb']),
50 'img_src': clean_url(result['urls']['raw']),
51 'title': result.get('alt_description') or 'unknown',
52 'content': result.get('description') or '',
53 }
54 )
55
56 return results

References searx.engines.unsplash.clean_url().

+ Here is the call graph for this function:

Variable Documentation

◆ about

dict searx.engines.unsplash.about
Initial value:
1= {
2 "website": 'https://unsplash.com',
3 "wikidata_id": 'Q28233552',
4 "official_api_documentation": 'https://unsplash.com/developers',
5 "use_official_api": False,
6 "require_api_key": False,
7 "results": 'JSON',
8}

Definition at line 10 of file unsplash.py.

◆ base_url

str searx.engines.unsplash.base_url = 'https://unsplash.com/'

Definition at line 19 of file unsplash.py.

◆ categories

list searx.engines.unsplash.categories = ['images']

Definition at line 21 of file unsplash.py.

◆ page_size

int searx.engines.unsplash.page_size = 20

Definition at line 22 of file unsplash.py.

◆ paging

bool searx.engines.unsplash.paging = True

Definition at line 23 of file unsplash.py.

◆ search_url

str searx.engines.unsplash.search_url = base_url + 'napi/search/photos?'

Definition at line 20 of file unsplash.py.