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

Functions

 request (query, params)
 
 response (resp)
 

Variables

dict about
 
list categories = ['it', 'repos']
 
str search_url = 'https://api.github.com/search/repositories?sort=stars&order=desc&{query}'
 
str accept_header = 'application/vnd.github.preview.text-match+json'
 

Detailed Description

Github (IT)

Function Documentation

◆ request()

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

Definition at line 27 of file github.py.

27def request(query, params):
28
29 params['url'] = search_url.format(query=urlencode({'q': query}))
30 params['headers']['Accept'] = accept_header
31
32 return params
33
34

◆ response()

searx.engines.github.response ( resp)

Definition at line 35 of file github.py.

35def response(resp):
36 results = []
37
38 for item in resp.json().get('items', []):
39 content = [item.get(i) for i in ['language', 'description'] if item.get(i)]
40
41 # license can be None
42 lic = item.get('license') or {}
43 lic_url = None
44 if lic.get('spdx_id'):
45 lic_url = f"https://spdx.org/licenses/{lic.get('spdx_id')}.html"
46
47 results.append(
48 {
49 'template': 'packages.html',
50 'url': item.get('html_url'),
51 'title': item.get('full_name'),
52 'content': ' / '.join(content),
53 'img_src': item.get('owner', {}).get('avatar_url'),
54 'package_name': item.get('name'),
55 # 'version': item.get('updated_at'),
56 'maintainer': item.get('owner', {}).get('login'),
57 'publishedDate': parser.parse(item.get("updated_at") or item.get("created_at")),
58 'tags': item.get('topics', []),
59 'popularity': item.get('stargazers_count'),
60 'license_name': lic.get('name'),
61 'license_url': lic_url,
62 'homepage': item.get('homepage'),
63 'source_code_url': item.get('clone_url'),
64 }
65 )
66
67 return results

Variable Documentation

◆ about

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

Definition at line 10 of file github.py.

◆ accept_header

str searx.engines.github.accept_header = 'application/vnd.github.preview.text-match+json'

Definition at line 24 of file github.py.

◆ categories

list searx.engines.github.categories = ['it', 'repos']

Definition at line 20 of file github.py.

◆ search_url

str searx.engines.github.search_url = 'https://api.github.com/search/repositories?sort=stars&order=desc&{query}'

Definition at line 23 of file github.py.