mirror of
				https://github.com/searxng/searxng.git
				synced 2025-11-03 19:17:07 -05:00 
			
		
		
		
	Merge pull request #94 from dalf/master
[enh] duckduckgo engine: add language support
This commit is contained in:
		
						commit
						d23dd7e276
					
				@ -18,7 +18,7 @@ from searx.utils import html_to_text
 | 
				
			|||||||
# engine dependent config
 | 
					# engine dependent config
 | 
				
			||||||
categories = ['general']
 | 
					categories = ['general']
 | 
				
			||||||
paging = True
 | 
					paging = True
 | 
				
			||||||
locale = 'us-en'
 | 
					language_support = True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# search-url
 | 
					# search-url
 | 
				
			||||||
url = 'https://duckduckgo.com/html?{query}&s={offset}'
 | 
					url = 'https://duckduckgo.com/html?{query}&s={offset}'
 | 
				
			||||||
@ -34,8 +34,13 @@ content_xpath = './/div[@class="snippet"]//text()'
 | 
				
			|||||||
def request(query, params):
 | 
					def request(query, params):
 | 
				
			||||||
    offset = (params['pageno'] - 1) * 30
 | 
					    offset = (params['pageno'] - 1) * 30
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if params['language'] == 'all':
 | 
				
			||||||
 | 
					        locale = 'en-us'
 | 
				
			||||||
 | 
					    else:
 | 
				
			||||||
 | 
					        locale = params['language'].replace('_','-').lower()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    params['url'] = url.format(
 | 
					    params['url'] = url.format(
 | 
				
			||||||
        query=urlencode({'q': query, 'l': locale}),
 | 
					        query=urlencode({'q': query, 'kl': locale}),
 | 
				
			||||||
        offset=offset)
 | 
					        offset=offset)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return params
 | 
					    return params
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user