add correction support for duckduckgo
This commit is contained in:
		
							parent
							
								
									6fb5c6aad9
								
							
						
					
					
						commit
						385e9b5c9e
					
				@ -50,6 +50,7 @@ result_xpath = '//div[@class="result results_links results_links_deep web-result
 | 
				
			|||||||
url_xpath = './/a[@class="result__a"]/@href'
 | 
					url_xpath = './/a[@class="result__a"]/@href'
 | 
				
			||||||
title_xpath = './/a[@class="result__a"]'
 | 
					title_xpath = './/a[@class="result__a"]'
 | 
				
			||||||
content_xpath = './/a[@class="result__snippet"]'
 | 
					content_xpath = './/a[@class="result__snippet"]'
 | 
				
			||||||
 | 
					correction_xpath = '//div[@id="did_you_mean"]//a'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# match query's language to a region code that duckduckgo will accept
 | 
					# match query's language to a region code that duckduckgo will accept
 | 
				
			||||||
@ -125,6 +126,11 @@ def response(resp):
 | 
				
			|||||||
                        'content': content,
 | 
					                        'content': content,
 | 
				
			||||||
                        'url': res_url})
 | 
					                        'url': res_url})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # parse correction
 | 
				
			||||||
 | 
					    for correction in eval_xpath(doc, correction_xpath):
 | 
				
			||||||
 | 
					        # append correction
 | 
				
			||||||
 | 
					        results.append({'correction': extract_text(correction)})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # return results
 | 
					    # return results
 | 
				
			||||||
    return results
 | 
					    return results
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user