Commit 63d5c799 authored by Nivesh Krishna's avatar Nivesh Krishna
Browse files

Merge branch 'fix-ddg-lang' into 'master'

fix lang selectors for ddg engine

Closes backlog#604

See merge request !134
parents b16644db 6032601e
...@@ -30,6 +30,15 @@ time_range_support = True ...@@ -30,6 +30,15 @@ time_range_support = True
safesearch = True safesearch = True
VQD_REGEX = r"vqd='(\d+-\d+-\d+)'" VQD_REGEX = r"vqd='(\d+-\d+-\d+)'"
language_aliases = { language_aliases = {
'ca-ES': 'ct-ca',
'de-AT': 'de-de',
'de-CH': 'de-de',
'es-AR': 'es-es',
'es-CL': 'es-es',
'es-MX': 'es-es',
'fr-BE': 'be-fr',
'fr-CA': 'ca-fr',
'fr-CH': 'ch-fr',
'ar-SA': 'ar-XA', 'ar-SA': 'ar-XA',
'es-419': 'es-XL', 'es-419': 'es-XL',
'ja': 'jp-JP', 'ja': 'jp-JP',
...@@ -75,7 +84,7 @@ def request(query, params): ...@@ -75,7 +84,7 @@ def request(query, params):
query_dict = { query_dict = {
"q": query, "q": query,
't': 'D', 't': 'D',
'l': params["language"], 'l': f"{dl}-{ct}",
'kl': f"{ct}-{dl}", 'kl': f"{ct}-{dl}",
's': (params['pageno'] - 1) * number_of_results, 's': (params['pageno'] - 1) * number_of_results,
'dl': dl, 'dl': dl,
...@@ -149,10 +158,15 @@ def response(resp): ...@@ -149,10 +158,15 @@ def response(resp):
for search_result in search_data: for search_result in search_data:
if 'n' in search_result: if 'n' in search_result:
continue continue
html2text = HTMLTextExtractor()
html2text.feed(search_result.get('a')) title = HTMLTextExtractor()
results.append({'title': search_result.get("t"), title.feed(search_result.get('t'))
'content': html2text.get_text(),
content = HTMLTextExtractor()
content.feed(search_result.get('a'))
results.append({'title': title.get_text(),
'content': content.get_text(),
'url': search_result.get('u')}) 'url': search_result.get('u')})
return results return results
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment