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

Functions

 request (query, params)
 
 response (resp)
 

Variables

dict about
 
list categories = ['social media']
 
bool paging = True
 
str search_url = "https://9gag.com/v1/search-posts?{query}"
 
int page_size = 10
 

Function Documentation

◆ request()

searx.engines.9gag.request ( query,
params )

Definition at line 25 of file 9gag.py.

25def request(query, params):
26 query = urlencode({'query': query, 'c': (params['pageno'] - 1) * page_size})
27
28 params['url'] = search_url.format(query=query)
29
30 return params
31
32

◆ response()

searx.engines.9gag.response ( resp)

Definition at line 33 of file 9gag.py.

33def response(resp):
34 results = []
35
36 json_results = loads(resp.text)['data']
37
38 for result in json_results['posts']:
39 result_type = result['type']
40
41 # Get the not cropped version of the thumbnail when the image height is not too important
42 if result['images']['image700']['height'] > 400:
43 thumbnail = result['images']['imageFbThumbnail']['url']
44 else:
45 thumbnail = result['images']['image700']['url']
46
47 if result_type == 'Photo':
48 results.append(
49 {
50 'template': 'images.html',
51 'url': result['url'],
52 'title': result['title'],
53 'content': result['description'],
54 'publishedDate': datetime.utcfromtimestamp(result['creationTs']),
55 'img_src': result['images']['image700']['url'],
56 'thumbnail_src': thumbnail,
57 }
58 )
59 elif result_type == 'Animated':
60 results.append(
61 {
62 'template': 'videos.html',
63 'url': result['url'],
64 'title': result['title'],
65 'content': result['description'],
66 'publishedDate': datetime.utcfromtimestamp(result['creationTs']),
67 'thumbnail': thumbnail,
68 'iframe_src': result['images'].get('image460sv', {}).get('url'),
69 }
70 )
71
72 if 'tags' in json_results:
73 for suggestion in json_results['tags']:
74 results.append({'suggestion': suggestion['key']})
75
76 return results

Variable Documentation

◆ about

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

Definition at line 9 of file 9gag.py.

◆ categories

list searx.engines.9gag.categories = ['social media']

Definition at line 18 of file 9gag.py.

◆ page_size

int searx.engines.9gag.page_size = 10

Definition at line 22 of file 9gag.py.

◆ paging

bool searx.engines.9gag.paging = True

Definition at line 19 of file 9gag.py.

◆ search_url

str searx.engines.9gag.search_url = "https://9gag.com/v1/search-posts?{query}"

Definition at line 21 of file 9gag.py.