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

Functions

 request (query, params)
 
 response (resp)
 

Variables

logging logger .Logger
 
dict about
 
list categories = ['videos', 'web']
 
bool paging = True
 
int max_page = 50
 
bool language_support = True
 
bool time_range_support = True
 
bool safesearch = True
 

Detailed Description

This is the implementation of the Google Videos engine.

.. admonition:: Content-Security-Policy (CSP)

   This engine needs to allow images from the `data URLs`_ (prefixed with the
   ``data:`` scheme)::

     Header set Content-Security-Policy "img-src 'self' data: ;"

.. _data URLs:
   https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs

Function Documentation

◆ request()

searx.engines.google_videos.request ( query,
params )
Google-Video search request

Definition at line 66 of file google_videos.py.

66def request(query, params):
67 """Google-Video search request"""
68
69 google_info = get_google_info(params, traits)
70
71 query_url = (
72 'https://'
73 + google_info['subdomain']
74 + '/search'
75 + "?"
76 + urlencode(
77 {
78 'q': query,
79 'tbm': "vid",
80 'start': 10 * params['pageno'],
81 **google_info['params'],
82 'asearch': 'arc',
83 'async': 'use_ac:true,_fmt:html',
84 }
85 )
86 )
87
88 if params['time_range'] in time_range_dict:
89 query_url += '&' + urlencode({'tbs': 'qdr:' + time_range_dict[params['time_range']]})
90 if 'safesearch' in params:
91 query_url += '&' + urlencode({'safe': filter_mapping[params['safesearch']]})
92 params['url'] = query_url
93
94 params['cookies'] = google_info['cookies']
95 params['headers'].update(google_info['headers'])
96 return params
97
98

◆ response()

searx.engines.google_videos.response ( resp)
Get response from google's search request

Definition at line 99 of file google_videos.py.

99def response(resp):
100 """Get response from google's search request"""
101 results = []
102
103 detect_google_sorry(resp)
104
105 # convert the text to dom
106 dom = html.fromstring(resp.text)
107
108 # parse results
109 for result in eval_xpath_list(dom, '//div[contains(@class, "g ")]'):
110
111 thumbnail = eval_xpath_getindex(result, './/img/@src', 0, None)
112 if thumbnail is None:
113 continue
114
115 title = extract_text(eval_xpath_getindex(result, './/a/h3[1]', 0))
116 url = eval_xpath_getindex(result, './/a/h3[1]/../@href', 0)
117
118 c_node = eval_xpath_getindex(result, './/div[@class="ITZIwc"]', 0)
119 content = extract_text(c_node)
120 pub_info = extract_text(eval_xpath(result, './/div[@class="gqF9jc"]'))
121
122 results.append(
123 {
124 'url': url,
125 'title': title,
126 'content': content,
127 'author': pub_info,
128 'thumbnail': thumbnail,
129 'iframe_src': get_embeded_stream_url(url),
130 'template': 'videos.html',
131 }
132 )
133
134 # parse suggestion
135 for suggestion in eval_xpath_list(dom, suggestion_xpath):
136 # append suggestion
137 results.append({'suggestion': extract_text(suggestion)})
138
139 return results

Variable Documentation

◆ about

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

Definition at line 47 of file google_videos.py.

◆ categories

list searx.engines.google_videos.categories = ['videos', 'web']

Definition at line 58 of file google_videos.py.

◆ language_support

bool searx.engines.google_videos.language_support = True

Definition at line 61 of file google_videos.py.

◆ logger

logging searx.engines.google_videos.logger .Logger

Definition at line 42 of file google_videos.py.

◆ max_page

int searx.engines.google_videos.max_page = 50

Definition at line 60 of file google_videos.py.

◆ paging

bool searx.engines.google_videos.paging = True

Definition at line 59 of file google_videos.py.

◆ safesearch

bool searx.engines.google_videos.safesearch = True

Definition at line 63 of file google_videos.py.

◆ time_range_support

bool searx.engines.google_videos.time_range_support = True

Definition at line 62 of file google_videos.py.