|  | @@ -0,0 +1,25 @@
 | 
	
		
			
			|  | 1 | +from urllib import urlencode
 | 
	
		
			
			|  | 2 | +from json import loads
 | 
	
		
			
			|  | 3 | +
 | 
	
		
			
			|  | 4 | +categories = ['it']
 | 
	
		
			
			|  | 5 | +
 | 
	
		
			
			|  | 6 | +search_url = 'https://api.github.com/search/repositories?sort=stars&order=desc&'
 | 
	
		
			
			|  | 7 | +
 | 
	
		
			
			|  | 8 | +def request(query, params):
 | 
	
		
			
			|  | 9 | +    global search_url
 | 
	
		
			
			|  | 10 | +    params['url'] = search_url + urlencode({'q': query})
 | 
	
		
			
			|  | 11 | +    params['headers']['Accept'] = 'application/vnd.github.preview.text-match+json'
 | 
	
		
			
			|  | 12 | +    return params
 | 
	
		
			
			|  | 13 | +
 | 
	
		
			
			|  | 14 | +
 | 
	
		
			
			|  | 15 | +def response(resp):
 | 
	
		
			
			|  | 16 | +    results = []
 | 
	
		
			
			|  | 17 | +    search_res = loads(resp.text)
 | 
	
		
			
			|  | 18 | +    if not 'items' in search_res:
 | 
	
		
			
			|  | 19 | +        return results
 | 
	
		
			
			|  | 20 | +    for res in search_res['items']:
 | 
	
		
			
			|  | 21 | +        title = res['name']
 | 
	
		
			
			|  | 22 | +        url = res['html_url']
 | 
	
		
			
			|  | 23 | +        content = res['description']
 | 
	
		
			
			|  | 24 | +        results.append({'url': url, 'title': title, 'content': content})
 | 
	
		
			
			|  | 25 | +    return results
 |