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

Functions

 request (query, params)
 
 response (resp)
 

Variables

dict about
 
list categories = ['images']
 
bool paging = True
 
bool time_range_support = True
 
str base_url = "https://imgur.com"
 
str results_xpath = "//div[contains(@class, 'cards')]/div[contains(@class, 'post')]"
 
str url_xpath = "./a/@href"
 
str title_xpath = "./a/img/@alt"
 
str thumbnail_xpath = "./a/img/@src"
 

Detailed Description

Imgur (images)

Function Documentation

◆ request()

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

Definition at line 30 of file imgur.py.

30def request(query, params):
31 time_range = params['time_range'] or 'all'
32 args = {
33 'q': query,
34 'qs': 'thumbs',
35 'p': params['pageno'] - 1,
36 }
37 params['url'] = f"{base_url}/search/score/{time_range}?{urlencode(args)}"
38 return params
39
40

◆ response()

searx.engines.imgur.response ( resp)

Definition at line 41 of file imgur.py.

41def response(resp):
42 results = []
43
44 dom = html.fromstring(resp.text)
45
46 for result in eval_xpath_list(dom, results_xpath):
47 thumbnail_src = extract_text(eval_xpath(result, thumbnail_xpath))
48 img_src = thumbnail_src.replace("b.", ".")
49
50 # that's a bug at imgur's side:
51 # sometimes there's just no preview image, hence we skip the image
52 if len(thumbnail_src) < 25:
53 continue
54
55 results.append(
56 {
57 'template': 'images.html',
58 'url': base_url + extract_text(eval_xpath(result, url_xpath)),
59 'title': extract_text(eval_xpath(result, title_xpath)),
60 'img_src': img_src,
61 'thumbnail_src': thumbnail_src,
62 }
63 )
64
65 return results

Variable Documentation

◆ about

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

Definition at line 9 of file imgur.py.

◆ base_url

str searx.engines.imgur.base_url = "https://imgur.com"

Definition at line 22 of file imgur.py.

◆ categories

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

Definition at line 18 of file imgur.py.

◆ paging

bool searx.engines.imgur.paging = True

Definition at line 19 of file imgur.py.

◆ results_xpath

str searx.engines.imgur.results_xpath = "//div[contains(@class, 'cards')]/div[contains(@class, 'post')]"

Definition at line 24 of file imgur.py.

◆ thumbnail_xpath

str searx.engines.imgur.thumbnail_xpath = "./a/img/@src"

Definition at line 27 of file imgur.py.

◆ time_range_support

bool searx.engines.imgur.time_range_support = True

Definition at line 20 of file imgur.py.

◆ title_xpath

str searx.engines.imgur.title_xpath = "./a/img/@alt"

Definition at line 26 of file imgur.py.

◆ url_xpath

str searx.engines.imgur.url_xpath = "./a/@href"

Definition at line 25 of file imgur.py.