mirror of
				https://github.com/searxng/searxng.git
				synced 2025-10-31 02:27:06 -04:00 
			
		
		
		
	[feat] engines: add uxwing engine for icons (#4819)
- uxwing provides attribution-free icons to use for design projects - svgrepo was my go-to before, but it's ratelimiting a lot recently
This commit is contained in:
		
							parent
							
								
									8bff73c9b6
								
							
						
					
					
						commit
						88973f5431
					
				
							
								
								
									
										50
									
								
								searx/engines/uxwing.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								searx/engines/uxwing.py
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,50 @@ | ||||
| # SPDX-License-Identifier: AGPL-3.0-or-later | ||||
| """UXwing (images)""" | ||||
| 
 | ||||
| from urllib.parse import quote_plus | ||||
| from lxml import html | ||||
| 
 | ||||
| from searx.utils import eval_xpath, eval_xpath_list, extract_text | ||||
| 
 | ||||
| about = { | ||||
|     "website": 'https://uxwing.com', | ||||
|     "wikidata_id": None, | ||||
|     "official_api_documentation": None, | ||||
|     "use_official_api": False, | ||||
|     "require_api_key": False, | ||||
|     "results": 'HTML', | ||||
| } | ||||
| categories = ['images', 'icons'] | ||||
| 
 | ||||
| base_url = "https://uxwing.com" | ||||
| 
 | ||||
| 
 | ||||
| def request(query, params): | ||||
|     params['url'] = f"{base_url}/?s={quote_plus(query)}" | ||||
|     return params | ||||
| 
 | ||||
| 
 | ||||
| def response(resp): | ||||
|     results = [] | ||||
| 
 | ||||
|     doc = html.fromstring(resp.text) | ||||
|     for result in eval_xpath_list(doc, "//article[starts-with(@id, 'post')]"): | ||||
|         classes = extract_text(eval_xpath(result, "./@class")).split(" ") | ||||
|         tags = [] | ||||
|         for css_class in classes: | ||||
|             for prefix in ("category", "tag"): | ||||
|                 if css_class.startswith(prefix): | ||||
|                     tag = css_class.removeprefix(prefix) | ||||
|                     tags.append(tag.replace("-", " ").title()) | ||||
| 
 | ||||
|         results.append( | ||||
|             { | ||||
|                 'template': 'images.html', | ||||
|                 'url': extract_text(eval_xpath(result, "./a/@href")), | ||||
|                 'img_src': extract_text(eval_xpath(result, ".//img/@src")), | ||||
|                 'title': extract_text(eval_xpath(result, ".//img/@alt")), | ||||
|                 'content': ', '.join(tags), | ||||
|             } | ||||
|         ) | ||||
| 
 | ||||
|     return results | ||||
| @ -2522,6 +2522,11 @@ engines: | ||||
|     engine: tootfinder | ||||
|     shortcut: toot | ||||
| 
 | ||||
|   - name: uxwing | ||||
|     engine: uxwing | ||||
|     shortcut: ux | ||||
|     disabled: true | ||||
| 
 | ||||
|   - name: voidlinux | ||||
|     engine: voidlinux | ||||
|     shortcut: void | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user