108 """Get response from google's search request"""
111 detect_google_sorry(resp)
112 data_image_map = parse_data_images(resp.text)
115 dom = html.fromstring(resp.text)
118 for result
in eval_xpath_list(dom,
'//div[contains(@class, "g ")]'):
120 thumbnail = eval_xpath_getindex(result,
'.//img/@src', 0,
None)
122 if thumbnail.startswith(
'data:image'):
123 img_id = eval_xpath_getindex(result,
'.//img/@id', 0,
None)
125 thumbnail = data_image_map.get(img_id)
129 title = extract_text(eval_xpath_getindex(result,
'.//a/h3[1]', 0))
130 url = eval_xpath_getindex(result,
'.//a/h3[1]/../@href', 0)
132 c_node = eval_xpath_getindex(result,
'.//div[contains(@class, "ITZIwc")]', 0)
133 content = extract_text(c_node)
134 pub_info = extract_text(eval_xpath(result,
'.//div[contains(@class, "gqF9jc")]'))
142 'thumbnail': thumbnail,
143 'iframe_src': get_embeded_stream_url(url),
144 'template':
'videos.html',
149 for suggestion
in eval_xpath_list(dom, suggestion_xpath):
151 results.append({
'suggestion': extract_text(suggestion)})