.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
 
EngineTraits traits
 
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 65 of file google_videos.py.

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

◆ response()

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

Definition at line 98 of file google_videos.py.

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

◆ categories

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

Definition at line 57 of file google_videos.py.

◆ language_support

bool searx.engines.google_videos.language_support = True

Definition at line 60 of file google_videos.py.

◆ logger

logging searx.engines.google_videos.logger .Logger

Definition at line 41 of file google_videos.py.

◆ max_page

int searx.engines.google_videos.max_page = 50

Definition at line 59 of file google_videos.py.

◆ paging

bool searx.engines.google_videos.paging = True

Definition at line 58 of file google_videos.py.

◆ safesearch

bool searx.engines.google_videos.safesearch = True

Definition at line 62 of file google_videos.py.

◆ time_range_support

bool searx.engines.google_videos.time_range_support = True

Definition at line 61 of file google_videos.py.

◆ traits

EngineTraits searx.engines.google_videos.traits

Definition at line 43 of file google_videos.py.