| 
				
			 | 
			
			
				@@ -13,7 +13,7 @@ 
			 | 
		
	
		
			
			| 
				13
			 | 
			
				13
			 | 
			
			
				 import json 
			 | 
		
	
		
			
			| 
				14
			 | 
			
				14
			 | 
			
			
				 from cgi import escape 
			 | 
		
	
		
			
			| 
				15
			 | 
			
				15
			 | 
			
			
				 from urllib import urlencode 
			 | 
		
	
		
			
			| 
				16
			 | 
			
				
			 | 
			
			
				-from urlparse import urlparse 
			 | 
		
	
		
			
			| 
				
			 | 
			
				16
			 | 
			
			
				+from urlparse import urlparse, urljoin 
			 | 
		
	
		
			
			| 
				17
			 | 
			
				17
			 | 
			
			
				 from datetime import datetime 
			 | 
		
	
		
			
			| 
				18
			 | 
			
				18
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				19
			 | 
			
				19
			 | 
			
			
				 # engine dependent config 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -21,7 +21,8 @@ categories = ['general', 'images', 'news', 'social media'] 
			 | 
		
	
		
			
			| 
				21
			 | 
			
				21
			 | 
			
			
				 page_size = 25 
			 | 
		
	
		
			
			| 
				22
			 | 
			
				22
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				23
			 | 
			
				23
			 | 
			
			
				 # search-url 
			 | 
		
	
		
			
			| 
				24
			 | 
			
				
			 | 
			
			
				-search_url = 'https://www.reddit.com/search.json?{query}' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				24
			 | 
			
			
				+base_url = 'https://www.reddit.com/' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				25
			 | 
			
			
				+search_url = base_url + 'search.json?{query}' 
			 | 
		
	
		
			
			| 
				25
			 | 
			
				26
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				26
			 | 
			
				27
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				27
			 | 
			
				28
			 | 
			
			
				 # do search-request 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -52,7 +53,7 @@ def response(resp): 
			 | 
		
	
		
			
			| 
				52
			 | 
			
				53
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				53
			 | 
			
				54
			 | 
			
			
				         # extract post information 
			 | 
		
	
		
			
			| 
				54
			 | 
			
				55
			 | 
			
			
				         params = { 
			 | 
		
	
		
			
			| 
				55
			 | 
			
				
			 | 
			
			
				-            'url': data['url'], 
			 | 
		
	
		
			
			| 
				
			 | 
			
				56
			 | 
			
			
				+            'url': urljoin(base_url, data['permalink']), 
			 | 
		
	
		
			
			| 
				56
			 | 
			
				57
			 | 
			
			
				             'title': data['title'] 
			 | 
		
	
		
			
			| 
				57
			 | 
			
				58
			 | 
			
			
				         } 
			 | 
		
	
		
			
			| 
				58
			 | 
			
				59
			 | 
			
			
				  
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -61,6 +62,7 @@ def response(resp): 
			 | 
		
	
		
			
			| 
				61
			 | 
			
				62
			 | 
			
			
				         url_info = urlparse(thumbnail) 
			 | 
		
	
		
			
			| 
				62
			 | 
			
				63
			 | 
			
			
				         # netloc & path 
			 | 
		
	
		
			
			| 
				63
			 | 
			
				64
			 | 
			
			
				         if url_info[1] != '' and url_info[2] != '': 
			 | 
		
	
		
			
			| 
				
			 | 
			
				65
			 | 
			
			
				+            params['img_src'] = data['url'] 
			 | 
		
	
		
			
			| 
				64
			 | 
			
				66
			 | 
			
			
				             params['thumbnail_src'] = thumbnail 
			 | 
		
	
		
			
			| 
				65
			 | 
			
				67
			 | 
			
			
				             params['template'] = 'images.html' 
			 | 
		
	
		
			
			| 
				66
			 | 
			
				68
			 | 
			
			
				             img_results.append(params) 
			 |