147 search_results = resp.json()
150 if not search_results.get(
'query', {}).get(
'search'):
153 for result
in search_results[
'query'][
'search']:
155 if result.get(
'snippet',
'').startswith(
'#REDIRECT'):
158 title = result[
'title']
159 sectiontitle = result.get(
'sectiontitle')
160 content = html_to_text(result.get(
'snippet',
''))
161 metadata = html_to_text(result.get(
'categorysnippet',
''))
162 timestamp = result.get(
'timestamp')
165 base_url.format(language=resp.search_params[
'language']) +
'wiki/' + quote(title.replace(
' ',
'_').encode())
169 url +=
'#' + quote(sectiontitle.replace(
' ',
'_').encode())
170 title +=
' / ' + sectiontitle
172 item = {
'url': url,
'title': title,
'content': content,
'metadata': metadata}
175 item[
'publishedDate'] = datetime.strptime(timestamp, timestamp_format)