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

Functions

 request (query, params)
 
 response (resp)
 

Variables

dict about
 
list categories = ['images']
 
bool paging = True
 
str base_url = 'https://www.deviantart.com'
 
str results_xpath = '//div[@class="_2pZkk"]/div/div/a'
 
str url_xpath = './@href'
 
str thumbnail_src_xpath = './div/img/@src'
 
str img_src_xpath = './div/img/@srcset'
 
str title_xpath = './@aria-label'
 
str premium_xpath = '../div/div/div/text()'
 
str premium_keytext = 'Watch the artist to view this deviation'
 
str cursor_xpath = '(//a[@class="_1OGeq"]/@href)[last()]'
 

Detailed Description

Deviantart (Images)

Function Documentation

◆ request()

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

Definition at line 38 of file deviantart.py.

38def request(query, params):
39
40 # https://www.deviantart.com/search?q=foo
41
42 nextpage_url = params['engine_data'].get('nextpage')
43 # don't use nextpage when user selected to jump back to page 1
44 if params['pageno'] > 1 and nextpage_url is not None:
45 params['url'] = nextpage_url
46 else:
47 params['url'] = f"{base_url}/search?{urllib.parse.urlencode({'q': query})}"
48
49 return params
50
51

◆ response()

searx.engines.deviantart.response ( resp)

Definition at line 52 of file deviantart.py.

52def response(resp):
53
54 results = []
55 dom = html.fromstring(resp.text)
56
57 for result in eval_xpath_list(dom, results_xpath):
58 # skip images that are blurred
59 _text = extract_text(eval_xpath(result, premium_xpath))
60 if _text and premium_keytext in _text:
61 continue
62 img_src = extract_text(eval_xpath(result, img_src_xpath))
63 if img_src:
64 img_src = img_src.split(' ')[0]
65 parsed_url = urllib.parse.urlparse(img_src)
66 img_src = parsed_url._replace(path=parsed_url.path.split('/v1')[0]).geturl()
67
68 results.append(
69 {
70 'template': 'images.html',
71 'url': extract_text(eval_xpath(result, url_xpath)),
72 'img_src': img_src,
73 'thumbnail_src': extract_text(eval_xpath(result, thumbnail_src_xpath)),
74 'title': extract_text(eval_xpath(result, title_xpath)),
75 }
76 )
77
78 nextpage_url = extract_text(eval_xpath(dom, cursor_xpath))
79 if nextpage_url:
80 results.append(
81 {
82 'engine_data': nextpage_url.replace("http://", "https://"),
83 'key': 'nextpage',
84 }
85 )
86
87 return results

Variable Documentation

◆ about

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

Definition at line 12 of file deviantart.py.

◆ base_url

str searx.engines.deviantart.base_url = 'https://www.deviantart.com'

Definition at line 26 of file deviantart.py.

◆ categories

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

Definition at line 22 of file deviantart.py.

◆ cursor_xpath

str searx.engines.deviantart.cursor_xpath = '(//a[@class="_1OGeq"]/@href)[last()]'

Definition at line 35 of file deviantart.py.

◆ img_src_xpath

str searx.engines.deviantart.img_src_xpath = './div/img/@srcset'

Definition at line 31 of file deviantart.py.

◆ paging

bool searx.engines.deviantart.paging = True

Definition at line 23 of file deviantart.py.

◆ premium_keytext

str searx.engines.deviantart.premium_keytext = 'Watch the artist to view this deviation'

Definition at line 34 of file deviantart.py.

◆ premium_xpath

str searx.engines.deviantart.premium_xpath = '../div/div/div/text()'

Definition at line 33 of file deviantart.py.

◆ results_xpath

str searx.engines.deviantart.results_xpath = '//div[@class="_2pZkk"]/div/div/a'

Definition at line 28 of file deviantart.py.

◆ thumbnail_src_xpath

str searx.engines.deviantart.thumbnail_src_xpath = './div/img/@src'

Definition at line 30 of file deviantart.py.

◆ title_xpath

str searx.engines.deviantart.title_xpath = './@aria-label'

Definition at line 32 of file deviantart.py.

◆ url_xpath

str searx.engines.deviantart.url_xpath = './@href'

Definition at line 29 of file deviantart.py.