|  | @@ -10,11 +10,11 @@
 | 
	
		
			
			| 10 | 10 |   @parse       url, title, content
 | 
	
		
			
			| 11 | 11 |  """
 | 
	
		
			
			| 12 | 12 |  
 | 
	
		
			
			| 13 |  | -from urllib import urlencode
 | 
	
		
			
			| 14 | 13 |  from cgi import escape
 | 
	
		
			
			| 15 |  | -from lxml import etree
 | 
	
		
			
			|  | 14 | +from json import loads
 | 
	
		
			
			| 16 | 15 |  from random import randint
 | 
	
		
			
			| 17 | 16 |  from time import time
 | 
	
		
			
			|  | 17 | +from urllib import urlencode
 | 
	
		
			
			| 18 | 18 |  
 | 
	
		
			
			| 19 | 19 |  # engine dependent config
 | 
	
		
			
			| 20 | 20 |  categories = ['general']
 | 
	
	
		
			
			|  | @@ -27,11 +27,11 @@ safesearch = True
 | 
	
		
			
			| 27 | 27 |  base_url = 'https://gigablast.com/'
 | 
	
		
			
			| 28 | 28 |  search_string = 'search?{query}'\
 | 
	
		
			
			| 29 | 29 |      '&n={number_of_results}'\
 | 
	
		
			
			|  | 30 | +    '&c=main'\
 | 
	
		
			
			| 30 | 31 |      '&s={offset}'\
 | 
	
		
			
			| 31 |  | -    '&format=xml'\
 | 
	
		
			
			|  | 32 | +    '&format=json'\
 | 
	
		
			
			| 32 | 33 |      '&qh=0'\
 | 
	
		
			
			| 33 |  | -    '&rxiyd={rxiyd}'\
 | 
	
		
			
			| 34 |  | -    '&rand={rand}'\
 | 
	
		
			
			|  | 34 | +    '&rxiwd={rxiwd}'\
 | 
	
		
			
			| 35 | 35 |      '&qlang={lang}'\
 | 
	
		
			
			| 36 | 36 |      '&ff={safesearch}'
 | 
	
		
			
			| 37 | 37 |  
 | 
	
	
		
			
			|  | @@ -59,8 +59,8 @@ def request(query, params):
 | 
	
		
			
			| 59 | 59 |      search_path = search_string.format(query=urlencode({'q': query}),
 | 
	
		
			
			| 60 | 60 |                                         offset=offset,
 | 
	
		
			
			| 61 | 61 |                                         number_of_results=number_of_results,
 | 
	
		
			
			| 62 |  | -                                       rxiyd=randint(10000, 10000000),
 | 
	
		
			
			| 63 |  | -                                       rand=int(time()),
 | 
	
		
			
			|  | 62 | +                                       rxiwd=1,
 | 
	
		
			
			|  | 63 | +                                       #  rand=int(time()),
 | 
	
		
			
			| 64 | 64 |                                         lang=language,
 | 
	
		
			
			| 65 | 65 |                                         safesearch=safesearch)
 | 
	
		
			
			| 66 | 66 |  
 | 
	
	
		
			
			|  | @@ -73,18 +73,14 @@ def request(query, params):
 | 
	
		
			
			| 73 | 73 |  def response(resp):
 | 
	
		
			
			| 74 | 74 |      results = []
 | 
	
		
			
			| 75 | 75 |  
 | 
	
		
			
			| 76 |  | -    dom = etree.fromstring(resp.content)
 | 
	
		
			
			| 77 |  | -
 | 
	
		
			
			| 78 | 76 |      # parse results
 | 
	
		
			
			| 79 |  | -    for result in dom.xpath(results_xpath):
 | 
	
		
			
			| 80 |  | -        url = result.xpath(url_xpath)[0].text
 | 
	
		
			
			| 81 |  | -        title = result.xpath(title_xpath)[0].text
 | 
	
		
			
			| 82 |  | -        content = escape(result.xpath(content_xpath)[0].text)
 | 
	
		
			
			|  | 77 | +    response_json = loads(resp.text)
 | 
	
		
			
			| 83 | 78 |  
 | 
	
		
			
			|  | 79 | +    for result in response_json['results']:
 | 
	
		
			
			| 84 | 80 |          # append result
 | 
	
		
			
			| 85 |  | -        results.append({'url': url,
 | 
	
		
			
			| 86 |  | -                        'title': title,
 | 
	
		
			
			| 87 |  | -                        'content': content})
 | 
	
		
			
			|  | 81 | +        results.append({'url': result['url'],
 | 
	
		
			
			|  | 82 | +                        'title': escape(result['title']),
 | 
	
		
			
			|  | 83 | +                        'content': escape(result['sum'])})
 | 
	
		
			
			| 88 | 84 |  
 | 
	
		
			
			| 89 | 85 |      # return results
 | 
	
		
			
			| 90 | 86 |      return results
 |