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

Functions

 request (query, params)
 
 response (resp)
 

Variables

dict about
 
list categories = ['social media']
 
str base_url = "https://www.tootfinder.ch"
 

Detailed Description

Tootfinder (social media)

Function Documentation

◆ request()

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

Definition at line 21 of file tootfinder.py.

21def request(query, params):
22 params['url'] = f"{base_url}/rest/api/search/{query}"
23 return params
24
25

◆ response()

searx.engines.tootfinder.response ( resp)

Definition at line 26 of file tootfinder.py.

26def response(resp):
27 results = []
28
29 # the API of tootfinder has an issue that errors on server side are appended to the API response as HTML
30 # thus we're only looking for the line that contains the actual json data and ignore everything else
31 json_str = ""
32 for line in resp.text.split("\n"):
33 if line.startswith("[{"):
34 json_str = line
35 break
36
37 for result in loads(json_str):
38 thumbnail = None
39
40 attachments = result.get('media_attachments', [])
41 images = [attachment['preview_url'] for attachment in attachments if attachment['type'] == 'image']
42 if len(images) > 0:
43 thumbnail = images[0]
44
45 title = result.get('card', {}).get('title')
46 if not title:
47 title = html_to_text(result['content'])[:75]
48
49 results.append(
50 {
51 'url': result['url'],
52 'title': title,
53 'content': html_to_text(result['content']),
54 'thumbnail': thumbnail,
55 'publishedDate': datetime.strptime(result['created_at'], '%Y-%m-%d %H:%M:%S'),
56 }
57 )
58
59 return results

Variable Documentation

◆ about

dict searx.engines.tootfinder.about
Initial value:
1= {
2 'website': "https://www.tootfinder.ch",
3 'official_api_documentation': "https://wiki.tootfinder.ch/index.php?name=the-tootfinder-rest-api",
4 'use_official_api': True,
5 'require_api_key': False,
6 'results': "JSON",
7}

Definition at line 9 of file tootfinder.py.

◆ base_url

str searx.engines.tootfinder.base_url = "https://www.tootfinder.ch"

Definition at line 18 of file tootfinder.py.

◆ categories

list searx.engines.tootfinder.categories = ['social media']

Definition at line 16 of file tootfinder.py.