42 search_results = json.loads(resp.text)
45 if 'data' not in search_results:
48 posts = search_results.get(
'data', {}).get(
'children', [])
55 params = {
'url': urljoin(base_url, data[
'permalink']),
'title': data[
'title']}
58 thumbnail = data[
'thumbnail']
59 url_info = urlparse(thumbnail)
61 if url_info[1] !=
'' and url_info[2] !=
'':
62 params[
'img_src'] = data[
'url']
63 params[
'thumbnail_src'] = thumbnail
64 params[
'template'] =
'images.html'
65 img_results.append(params)
67 created = datetime.fromtimestamp(data[
'created_utc'])
68 content = data[
'selftext']
69 if len(content) > 500:
70 content = content[:500] +
'...'
71 params[
'content'] = content
72 params[
'publishedDate'] = created
73 text_results.append(params)
76 return img_results + text_results